prettypretty

Macro rgb

Source
macro_rules! rgb {
    ($r:expr, $g:expr, $b:expr) => { ... };
}
Expand description

Create a new sRGB color from 24-bit integer coordinates.

Like Color::from_24bit, this macro creates a new color from 24-bit integer coordinates. However, it also is safe to use in const expressions.

Rust currently does not allow floating point operations in const functions. That makes it impossible to write a const function that constructs a new high-resolution color object from integer coordinates. However, Rust does currently allow floating point operations in const expressions, notably as arguments to a const function such as a constructor. Hence, a macro can convert and normalize the integer coordinates before passing them to the const function. That’s just what this macro does.