Macro pix_engine::hsb

source ·
macro_rules! hsb {
    ($gray:expr) => { ... };
    ($gray:expr, $a:expr$(,)?) => { ... };
    ($h:expr, $s:expr, $b:expr$(,)?) => { ... };
    ($h:expr, $s:expr, $b:expr, $a:expr$(,)?) => { ... };
}
Expand description

Constructs a Color with hue, saturation, brightness and optional alpha.

Examples

let c = hsb!(50.0); // Gray
assert_eq!(c.channels(), [128, 128, 128, 255]);

let c = hsb!(50.0, 0.5); // Gray with alpha
assert_eq!(c.channels(), [128, 128, 128, 128]);

let c = hsb!(342.0, 100.0, 80.0); // Hue, Saturation, Brightness
assert_eq!(c.channels(), [204, 0, 61, 255]);

let c = hsb!(342.0, 100.0, 80.0, 0.5); // Hue, Saturation, Brightness, Alpha
assert_eq!(c.channels(), [204, 0, 61, 128]);