Macro pix_engine::color

source ·
macro_rules! color {
    ($gray:expr) => { ... };
    ($gray:expr, $a:expr$(,)?) => { ... };
    ($r:expr, $g:expr, $b:expr$(,)?) => { ... };
    ($r:expr, $g:expr, $b:expr, $a:expr$(,)?) => { ... };
}
Expand description

Constructs a Color with red, green, blue and optional alpha.

Examples

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

let c = color!(128, 64); // Gray with alpha
assert_eq!(c.channels(), [128, 128, 128, 64]);

let c = color!(128, 64, 0); // Red, Green, Blue
assert_eq!(c.channels(), [128, 64, 0, 255]);

let c = color!(128, 64, 128, 128); // Red, Green, Blue, Alpha
assert_eq!(c.channels(), [128, 64, 128, 128]);