color
ModuleColours as ImageMagick reads them from strings.
Contents
use utopia_image::Color;Rust
pub struct Color(pub [u8; 4])An RGBA colour with 8 bits per channel (alpha 255 is opaque).
Parsed from the strings ImageMagick accepts for borders and backgrounds:
#rgb, #rgba, #rrggbb, #rrggbbaa, rgb(r, g, b), rgba(r, g, b, a)
(channels as 0–255 or percentages, alpha as 0–1), the CSS colour names,
transparent and none. The empty string is ImageMagick's background
colour, white.
Rust
use utopia_image::Color;
assert_eq!(Color::parse("#ff000080")?, Color::rgba(255, 0, 0, 128));
assert_eq!(Color::parse("red")?, Color::rgba(255, 0, 0, 255));
assert!(Color::parse("notacolor").is_err());