fn calculate_target_value(
    signum: Option<bool>,
    percent: u8,
    current: u16,
    max: u16,
    min: u16,
) -> u16 {
    let value: u16 = (max as f32 * percent as f32 / 100.0) as u16;
    match signum {
        Some(positive) => {
            let new_value = if positive {
                current.saturating_add(value)
            } else {
                current.saturating_sub(value)
            };
            if new_value >= max {
                max
            } else if new_value <= min {
                min
            } else {
                new_value
            }
        }
        None => {
            if value >= max {
                max
            } else if value <= min {
                min
            } else {
                value
            }
        }
    }
}
/// Calculates the actual brigthness value, given the min-max-range and percent value.
/// If a signum is given, the percentage value will be added//subtracted to the current
/// brightness value.
/// In any case, this method returns the absolute target brigthness value.
/// signum: Relativizes the `percent` value. `None` means the given `percent` value is
/// meant to be an absolute target value. `Some(true)` means the target is the current
/// value added to the percentage. `Some(false)` means the target is the subtraction of
/// the current value and the given percentage.
/// percent: Percentage of wanted target value. Expected to be between 0 - 100.
/// current: the current absolute brightness value (not a percentage).
/// max: the maximum absolute brightness value.
/// min: the minimum absolute brigthness value.
Calculates the actual brigthness value, given the min-max-range and percent value.
If a signum is given, the percentage value will be added//subtracted to the current
brightness value.
In any case, this method returns the absolute target brigthness value.
signum: Relativizes the `percent` value. `None` means the given `percent` value is
meant to be an absolute target value. `Some(true)` means the target is the current
value added to the percentage. `Some(false)` means the target is the subtraction of
the current value and the given percentage.
percent: Percentage of wanted target value. Expected to be between 0 - 100.
current: the current absolute brightness value (not a percentage).
max: the maximum absolute brightness value.
min: the minimum absolute brigthness value.
Calculates the actual brigthness value given the min - max - range and percent value . If a signum is given the percentage value will be added // subtracted to the current brightness value . In any case this method returns the absolute target brigthness value . signum : Relativizes the ` percent ` value . ` None ` means the given ` percent ` value is meant to be an absolute target value . ` Some ( true ) ` means the target is the current value added to the percentage . ` Some ( false ) ` means the target is the subtraction of the current value and the given percentage . percent : Percentage of wanted target value . Expected to be between 0 - 100 . current : the current absolute brightness value ( not a percentage ) . max : the maximum absolute brightness value . min : the minimum absolute brigthness value .
fn calculate_target_value(
    signum: Option<bool>,
    percent: u8,
    current: u16,
    max: u16,
    min: u16,
) -> u16 {
    let value: u16 = (max as f32 * percent as f32 / 100.0) as u16;
    match signum {
        Some(positive) => {
            let new_value = if positive {
                current.saturating_add(value)
            } else {
                current.saturating_sub(value)
            };
            if new_value >= max {
                max
            } else if new_value <= min {
                min
            } else {
                new_value
            }
        }
        None => {
            if value >= max {
                max
            } else if value <= min {
                min
            } else {
                value
            }
        }
    }
}
fn calculate_target_value ( signum : Option < bool > , percent : u8 , current : u16 , max : u16 , min : u16 , ) -> u16 { let value : u16 = ( max as f32 * percent as f32 / 100.0 ) as u16 ; match signum { Some ( positive ) => { let new_value = if positive { current . saturating_add ( value ) } else { current . saturating_sub ( value ) } ; if new_value >= max { max } else if new_value <= min { min } else { new_value } } None => { if value >= max { max } else if value <= min { min } else { value } } } }
Calculates the actual brigthness value, given the min-max-range and percent value.
Calculates the actual brigthness value given the min - max - range and percent value .
signum
Option<bool>
percent
u8
current
u16
max
u16
min
u16
signum
Option<bool>
percent
u8
current
u16
max
u16
min
u16