Module palette::named

source ·
Expand description

A collection of named color constants. Can be toggled with the "named" and "named_from_str" Cargo features.

They are taken from the SVG keyword colors (same as in CSS3) and they can be used as if they were pixel values:

use palette::Srgb;
use palette::named;

//From constant
let from_const = Srgb::<f32>::from_format(named::OLIVE).into_linear();

//From name string
let olive = named::from_str("olive").expect("unknown color");
let from_str = Srgb::<f32>::from_format(olive).into_linear();

assert_eq!(from_const, from_str);

Constants§

Functions§

  • Get a SVG/CSS3 color by name. Can be toggled with the "named_from_str" Cargo feature.