inku
An RGBA [Color
] backed by a u32
.
Examples
type RGBA = Color;
let color = RGBA new;
let new_color = color
// Lighten the color by 10%
.lighten
// Saturate the color by 30%
.saturate;
assert_eq!;
// 4 bytes
assert_eq!;
Storage Formats
An RGBA color backed by a u32
.
There are multiple storage formats to choose from, [ZRGB
] and [RGBA
]. These determine how
the underlying u32
is laid out.
type RGBA = Color;
type ZRGB = Color;
assert_eq!;
// NOTE: The high byte is zeroed out
assert_eq!;
Manipulations are lossy
Because we're representing the colour with a u32
, manipulations are not reversible.
Consider the following:
type RGBA = Color;
let color = RGBA new;
// We convert the RGB values to HSL and desaturated the color
let desaturated_color = color.desaturate;
assert_eq!;
// We don't know what our original hue was, so we can't get back to the original color
let resaturated_color = desaturated_color.saturate;
assert_eq!;
License: MIT OR Apache-2.0