Debian Codegraph @

src/named.rs

raw symbols SCIP
1 //! A collection of named color constants. Can be toggled with the `"named"` and
2 //! `"named_from_str"` Cargo features.
3 //!
4 //! They are taken from the [SVG keyword
5 //! colors](https://www.w3.org/TR/SVG11/types.html#ColorKeywords) (same as in
6 //! CSS3) and they can be used as if they were pixel values:
7 //!
8 //! ```
9 //! use palette::Srgb;
10 //! use palette::named;
11 //!
12 //! //From constant
13 //! let from_const = Srgb::<f32>::from_format(named::OLIVE).into_linear();
14 #![cfg_attr(feature = "named_from_str", doc = "")]
15 #![cfg_attr(feature = "named_from_str", doc = "//From name string")]
16 #![cfg_attr(feature = "named_from_str", doc = "let olive = named::from_str(\"olive\").expect(\"unknown color\");")]
17 #![cfg_attr(feature = "named_from_str", doc = "let from_str = Srgb::<f32>::from_format(olive).into_linear();")]
18 #![cfg_attr(feature = "named_from_str", doc = "")]
19 #![cfg_attr(feature = "named_from_str", doc = "assert_eq!(from_const, from_str);")]
20 //! ```
21
22 includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include!!(concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!(envrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/env!!("OUT_DIR"), "/named.rs"));
23
24 /// Get a SVG/CSS3 color by name. Can be toggled with the `"named_from_str"`
25 /// Cargo feature.
26 ///
27 /// The names are the same as the constants, but lower case.
28 #[cfg(feature = "named_from_str")]
29 pub fn from_strrust-analyzer cargo palette 0.7.6 named/from_str().(name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<craterust-analyzer cargo palette 0.7.6 crate/::Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<u8>> {
30 COLORSrust-analyzer cargo palette 0.7.6 named/COLORS..getrust-analyzer cargo phf 0.11.2 map/impl#[`Map<K, V>`]get().(name).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().()
31 }