diff --git a/Cargo.toml b/Cargo.toml index 41e81ad..b16a8e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ codemap = "0.1.3" peekmore = "0.5.2" wasm-bindgen = { version = "0.2.65", optional = true } beef = "0.4.4" +phf = { version = "0.8.0", features = ["macros"] } # criterion is not a dev-dependency because it makes tests take too # long to compile, and you cannot make dev-dependencies optional criterion = { version = "0.3.3", optional = true } diff --git a/benches/colors.rs b/benches/colors.rs index f4e63fc..d96a8c8 100644 --- a/benches/colors.rs +++ b/benches/colors.rs @@ -1,18 +1,23 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use grass::StyleSheet; pub fn many_hsla(c: &mut Criterion) { c.bench_function("many_hsla", |b| { - b.iter(|| StyleSheet::new(black_box(include_str!("many_hsla.scss").to_string()))) + b.iter(|| { + grass::from_string( + black_box(include_str!("many_hsla.scss").to_string()), + &Default::default(), + ) + }) }); } pub fn many_named_colors(c: &mut Criterion) { c.bench_function("many_named_colors", |b| { b.iter(|| { - StyleSheet::new(black_box( - include_str!("many_named_colors.scss").to_string(), - )) + grass::from_string( + black_box(include_str!("many_named_colors.scss").to_string()), + &Default::default(), + ) }) }); } diff --git a/src/color/name.rs b/src/color/name.rs index 2461c33..9a0bf00 100644 --- a/src/color/name.rs +++ b/src/color/name.rs @@ -1,27 +1,12 @@ //! A big dictionary of named colors and their //! corresponding RGBA values -use once_cell::sync::Lazy; -use std::collections::HashMap; - pub(crate) struct NamedColorMap { - name_to_rgba: HashMap<&'static str, [u8; 4]>, - rgba_to_name: HashMap<[u8; 4], &'static str>, + name_to_rgba: phf::Map<&'static str, [u8; 4]>, + rgba_to_name: phf::Map<[u8; 4], &'static str>, } impl NamedColorMap { - pub fn with_capacity(capacity: usize) -> Self { - Self { - name_to_rgba: HashMap::with_capacity(capacity), - rgba_to_name: HashMap::with_capacity(capacity), - } - } - - pub fn insert(&mut self, name: &'static str, rgba: [u8; 4]) { - self.name_to_rgba.insert(name, rgba); - self.rgba_to_name.insert(rgba, name); - } - pub fn get_by_name(&self, name: &str) -> Option<&[u8; 4]> { self.name_to_rgba.get(name) } @@ -31,147 +16,290 @@ impl NamedColorMap { } } -pub(crate) static NAMED_COLORS: Lazy = Lazy::new(|| { - let mut m = NamedColorMap::with_capacity(150); - m.insert("aliceblue", [0xF0, 0xF8, 0xFF, 0xFF]); - m.insert("antiquewhite", [0xFA, 0xEB, 0xD7, 0xFF]); - m.insert("aqua", [0x00, 0xFF, 0xFF, 0xFF]); - m.insert("aquamarine", [0x7F, 0xFF, 0xD4, 0xFF]); - m.insert("azure", [0xF0, 0xFF, 0xFF, 0xFF]); - m.insert("beige", [0xF5, 0xF5, 0xDC, 0xFF]); - m.insert("bisque", [0xFF, 0xE4, 0xC4, 0xFF]); - m.insert("black", [0x00, 0x00, 0x00, 0xFF]); - m.insert("blanchedalmond", [0xFF, 0xEB, 0xCD, 0xFF]); - m.insert("blue", [0x00, 0x00, 0xFF, 0xFF]); - m.insert("blueviolet", [0x8A, 0x2B, 0xE2, 0xFF]); - m.insert("brown", [0xA5, 0x2A, 0x2A, 0xFF]); - m.insert("burlywood", [0xDE, 0xB8, 0x87, 0xFF]); - m.insert("cadetblue", [0x5F, 0x9E, 0xA0, 0xFF]); - m.insert("chartreuse", [0x7F, 0xFF, 0x00, 0xFF]); - m.insert("chocolate", [0xD2, 0x69, 0x1E, 0xFF]); - m.insert("coral", [0xFF, 0x7F, 0x50, 0xFF]); - m.insert("cornflowerblue", [0x64, 0x95, 0xED, 0xFF]); - m.insert("cornsilk", [0xFF, 0xF8, 0xDC, 0xFF]); - m.insert("crimson", [0xDC, 0x14, 0x3C, 0xFF]); - m.insert("darkblue", [0x00, 0x00, 0x8B, 0xFF]); - m.insert("darkcyan", [0x00, 0x8B, 0x8B, 0xFF]); - m.insert("darkgoldenrod", [0xB8, 0x86, 0x0B, 0xFF]); - m.insert("darkgray", [0xA9, 0xA9, 0xA9, 0xFF]); - m.insert("darkgreen", [0x00, 0x64, 0x00, 0xFF]); - m.insert("darkkhaki", [0xBD, 0xB7, 0x6B, 0xFF]); - m.insert("darkmagenta", [0x8B, 0x00, 0x8B, 0xFF]); - m.insert("darkolivegreen", [0x55, 0x6B, 0x2F, 0xFF]); - m.insert("darkorange", [0xFF, 0x8C, 0x00, 0xFF]); - m.insert("darkorchid", [0x99, 0x32, 0xCC, 0xFF]); - m.insert("darkred", [0x8B, 0x00, 0x00, 0xFF]); - m.insert("darksalmon", [0xE9, 0x96, 0x7A, 0xFF]); - m.insert("darkseagreen", [0x8F, 0xBC, 0x8F, 0xFF]); - m.insert("darkslateblue", [0x48, 0x3D, 0x8B, 0xFF]); - m.insert("darkslategray", [0x2F, 0x4F, 0x4F, 0xFF]); - m.insert("darkturquoise", [0x00, 0xCE, 0xD1, 0xFF]); - m.insert("darkviolet", [0x94, 0x00, 0xD3, 0xFF]); - m.insert("deeppink", [0xFF, 0x14, 0x93, 0xFF]); - m.insert("deepskyblue", [0x00, 0xBF, 0xFF, 0xFF]); - m.insert("dimgray", [0x69, 0x69, 0x69, 0xFF]); - m.insert("dodgerblue", [0x1E, 0x90, 0xFF, 0xFF]); - m.insert("firebrick", [0xB2, 0x22, 0x22, 0xFF]); - m.insert("floralwhite", [0xFF, 0xFA, 0xF0, 0xFF]); - m.insert("forestgreen", [0x22, 0x8B, 0x22, 0xFF]); - m.insert("fuchsia", [0xFF, 0x00, 0xFF, 0xFF]); - m.insert("gainsboro", [0xDC, 0xDC, 0xDC, 0xFF]); - m.insert("ghostwhite", [0xF8, 0xF8, 0xFF, 0xFF]); - m.insert("gold", [0xFF, 0xD7, 0x00, 0xFF]); - m.insert("goldenrod", [0xDA, 0xA5, 0x20, 0xFF]); - m.insert("gray", [0x80, 0x80, 0x80, 0xFF]); - m.insert("green", [0x00, 0x80, 0x00, 0xFF]); - m.insert("greenyellow", [0xAD, 0xFF, 0x2F, 0xFF]); - m.insert("honeydew", [0xF0, 0xFF, 0xF0, 0xFF]); - m.insert("hotpink", [0xFF, 0x69, 0xB4, 0xFF]); - m.insert("indianred", [0xCD, 0x5C, 0x5C, 0xFF]); - m.insert("indigo", [0x4B, 0x00, 0x82, 0xFF]); - m.insert("ivory", [0xFF, 0xFF, 0xF0, 0xFF]); - m.insert("khaki", [0xF0, 0xE6, 0x8C, 0xFF]); - m.insert("lavender", [0xE6, 0xE6, 0xFA, 0xFF]); - m.insert("lavenderblush", [0xFF, 0xF0, 0xF5, 0xFF]); - m.insert("lawngreen", [0x7C, 0xFC, 0x00, 0xFF]); - m.insert("lemonchiffon", [0xFF, 0xFA, 0xCD, 0xFF]); - m.insert("lightblue", [0xAD, 0xD8, 0xE6, 0xFF]); - m.insert("lightcoral", [0xF0, 0x80, 0x80, 0xFF]); - m.insert("lightcyan", [0xE0, 0xFF, 0xFF, 0xFF]); - m.insert("lightgoldenrodyellow", [0xFA, 0xFA, 0xD2, 0xFF]); - m.insert("lightgray", [0xD3, 0xD3, 0xD3, 0xFF]); - m.insert("lightgreen", [0x90, 0xEE, 0x90, 0xFF]); - m.insert("lightpink", [0xFF, 0xB6, 0xC1, 0xFF]); - m.insert("lightsalmon", [0xFF, 0xA0, 0x7A, 0xFF]); - m.insert("lightseagreen", [0x20, 0xB2, 0xAA, 0xFF]); - m.insert("lightskyblue", [0x87, 0xCE, 0xFA, 0xFF]); - m.insert("lightslategray", [0x77, 0x88, 0x99, 0xFF]); - m.insert("lightsteelblue", [0xB0, 0xC4, 0xDE, 0xFF]); - m.insert("lightyellow", [0xFF, 0xFF, 0xE0, 0xFF]); - m.insert("lime", [0x00, 0xFF, 0x00, 0xFF]); - m.insert("limegreen", [0x32, 0xCD, 0x32, 0xFF]); - m.insert("linen", [0xFA, 0xF0, 0xE6, 0xFF]); - m.insert("maroon", [0x80, 0x00, 0x00, 0xFF]); - m.insert("mediumaquamarine", [0x66, 0xCD, 0xAA, 0xFF]); - m.insert("mediumblue", [0x00, 0x00, 0xCD, 0xFF]); - m.insert("mediumorchid", [0xBA, 0x55, 0xD3, 0xFF]); - m.insert("mediumpurple", [0x93, 0x70, 0xDB, 0xFF]); - m.insert("mediumseagreen", [0x3C, 0xB3, 0x71, 0xFF]); - m.insert("mediumslateblue", [0x7B, 0x68, 0xEE, 0xFF]); - m.insert("mediumspringgreen", [0x00, 0xFA, 0x9A, 0xFF]); - m.insert("mediumturquoise", [0x48, 0xD1, 0xCC, 0xFF]); - m.insert("mediumvioletred", [0xC7, 0x15, 0x85, 0xFF]); - m.insert("midnightblue", [0x19, 0x19, 0x70, 0xFF]); - m.insert("mintcream", [0xF5, 0xFF, 0xFA, 0xFF]); - m.insert("mistyrose", [0xFF, 0xE4, 0xE1, 0xFF]); - m.insert("moccasin", [0xFF, 0xE4, 0xB5, 0xFF]); - m.insert("navajowhite", [0xFF, 0xDE, 0xAD, 0xFF]); - m.insert("navy", [0x00, 0x00, 0x80, 0xFF]); - m.insert("oldlace", [0xFD, 0xF5, 0xE6, 0xFF]); - m.insert("olive", [0x80, 0x80, 0x00, 0xFF]); - m.insert("olivedrab", [0x6B, 0x8E, 0x23, 0xFF]); - m.insert("orange", [0xFF, 0xA5, 0x00, 0xFF]); - m.insert("orangered", [0xFF, 0x45, 0x00, 0xFF]); - m.insert("orchid", [0xDA, 0x70, 0xD6, 0xFF]); - m.insert("palegoldenrod", [0xEE, 0xE8, 0xAA, 0xFF]); - m.insert("palegreen", [0x98, 0xFB, 0x98, 0xFF]); - m.insert("paleturquoise", [0xAF, 0xEE, 0xEE, 0xFF]); - m.insert("palevioletred", [0xDB, 0x70, 0x93, 0xFF]); - m.insert("papayawhip", [0xFF, 0xEF, 0xD5, 0xFF]); - m.insert("peachpuff", [0xFF, 0xDA, 0xB9, 0xFF]); - m.insert("peru", [0xCD, 0x85, 0x3F, 0xFF]); - m.insert("pink", [0xFF, 0xC0, 0xCB, 0xFF]); - m.insert("plum", [0xDD, 0xA0, 0xDD, 0xFF]); - m.insert("powderblue", [0xB0, 0xE0, 0xE6, 0xFF]); - m.insert("purple", [0x80, 0x00, 0x80, 0xFF]); - m.insert("rebeccapurple", [0x66, 0x33, 0x99, 0xFF]); - m.insert("red", [0xFF, 0x00, 0x00, 0xFF]); - m.insert("rosybrown", [0xBC, 0x8F, 0x8F, 0xFF]); - m.insert("royalblue", [0x41, 0x69, 0xE1, 0xFF]); - m.insert("saddlebrown", [0x8B, 0x45, 0x13, 0xFF]); - m.insert("salmon", [0xFA, 0x80, 0x72, 0xFF]); - m.insert("sandybrown", [0xF4, 0xA4, 0x60, 0xFF]); - m.insert("seagreen", [0x2E, 0x8B, 0x57, 0xFF]); - m.insert("seashell", [0xFF, 0xF5, 0xEE, 0xFF]); - m.insert("sienna", [0xA0, 0x52, 0x2D, 0xFF]); - m.insert("silver", [0xC0, 0xC0, 0xC0, 0xFF]); - m.insert("skyblue", [0x87, 0xCE, 0xEB, 0xFF]); - m.insert("slateblue", [0x6A, 0x5A, 0xCD, 0xFF]); - m.insert("slategray", [0x70, 0x80, 0x90, 0xFF]); - m.insert("snow", [0xFF, 0xFA, 0xFA, 0xFF]); - m.insert("springgreen", [0x00, 0xFF, 0x7F, 0xFF]); - m.insert("steelblue", [0x46, 0x82, 0xB4, 0xFF]); - m.insert("tan", [0xD2, 0xB4, 0x8C, 0xFF]); - m.insert("teal", [0x00, 0x80, 0x80, 0xFF]); - m.insert("thistle", [0xD8, 0xBF, 0xD8, 0xFF]); - m.insert("tomato", [0xFF, 0x63, 0x47, 0xFF]); - m.insert("turquoise", [0x40, 0xE0, 0xD0, 0xFF]); - m.insert("violet", [0xEE, 0x82, 0xEE, 0xFF]); - m.insert("wheat", [0xF5, 0xDE, 0xB3, 0xFF]); - m.insert("white", [0xFF, 0xFF, 0xFF, 0xFF]); - m.insert("whitesmoke", [0xF5, 0xF5, 0xF5, 0xFF]); - m.insert("yellow", [0xFF, 0xFF, 0x00, 0xFF]); - m.insert("yellowgreen", [0x9A, 0xCD, 0x32, 0xFF]); - m.insert("transparent", [0x00, 0x00, 0x00, 0x00]); - m -}); +// Adding one color requires adding to both map due to limitation in phf crate. +pub(crate) static NAMED_COLORS: NamedColorMap = NamedColorMap { + name_to_rgba: phf::phf_map! { + "aliceblue" => [0xF0, 0xF8, 0xFF, 0xFF], + "antiquewhite" => [0xFA, 0xEB, 0xD7, 0xFF], + "aqua" => [0x00, 0xFF, 0xFF, 0xFF], + "aquamarine" => [0x7F, 0xFF, 0xD4, 0xFF], + "azure" => [0xF0, 0xFF, 0xFF, 0xFF], + "beige" => [0xF5, 0xF5, 0xDC, 0xFF], + "bisque" => [0xFF, 0xE4, 0xC4, 0xFF], + "black" => [0x00, 0x00, 0x00, 0xFF], + "blanchedalmond" => [0xFF, 0xEB, 0xCD, 0xFF], + "blue" => [0x00, 0x00, 0xFF, 0xFF], + "blueviolet" => [0x8A, 0x2B, 0xE2, 0xFF], + "brown" => [0xA5, 0x2A, 0x2A, 0xFF], + "burlywood" => [0xDE, 0xB8, 0x87, 0xFF], + "cadetblue" => [0x5F, 0x9E, 0xA0, 0xFF], + "chartreuse" => [0x7F, 0xFF, 0x00, 0xFF], + "chocolate" => [0xD2, 0x69, 0x1E, 0xFF], + "coral" => [0xFF, 0x7F, 0x50, 0xFF], + "cornflowerblue" => [0x64, 0x95, 0xED, 0xFF], + "cornsilk" => [0xFF, 0xF8, 0xDC, 0xFF], + "crimson" => [0xDC, 0x14, 0x3C, 0xFF], + "darkblue" => [0x00, 0x00, 0x8B, 0xFF], + "darkcyan" => [0x00, 0x8B, 0x8B, 0xFF], + "darkgoldenrod" => [0xB8, 0x86, 0x0B, 0xFF], + "darkgray" => [0xA9, 0xA9, 0xA9, 0xFF], + "darkgreen" => [0x00, 0x64, 0x00, 0xFF], + "darkkhaki" => [0xBD, 0xB7, 0x6B, 0xFF], + "darkmagenta" => [0x8B, 0x00, 0x8B, 0xFF], + "darkolivegreen" => [0x55, 0x6B, 0x2F, 0xFF], + "darkorange" => [0xFF, 0x8C, 0x00, 0xFF], + "darkorchid" => [0x99, 0x32, 0xCC, 0xFF], + "darkred" => [0x8B, 0x00, 0x00, 0xFF], + "darksalmon" => [0xE9, 0x96, 0x7A, 0xFF], + "darkseagreen" => [0x8F, 0xBC, 0x8F, 0xFF], + "darkslateblue" => [0x48, 0x3D, 0x8B, 0xFF], + "darkslategray" => [0x2F, 0x4F, 0x4F, 0xFF], + "darkturquoise" => [0x00, 0xCE, 0xD1, 0xFF], + "darkviolet" => [0x94, 0x00, 0xD3, 0xFF], + "deeppink" => [0xFF, 0x14, 0x93, 0xFF], + "deepskyblue" => [0x00, 0xBF, 0xFF, 0xFF], + "dimgray" => [0x69, 0x69, 0x69, 0xFF], + "dodgerblue" => [0x1E, 0x90, 0xFF, 0xFF], + "firebrick" => [0xB2, 0x22, 0x22, 0xFF], + "floralwhite" => [0xFF, 0xFA, 0xF0, 0xFF], + "forestgreen" => [0x22, 0x8B, 0x22, 0xFF], + "fuchsia" => [0xFF, 0x00, 0xFF, 0xFF], + "gainsboro" => [0xDC, 0xDC, 0xDC, 0xFF], + "ghostwhite" => [0xF8, 0xF8, 0xFF, 0xFF], + "gold" => [0xFF, 0xD7, 0x00, 0xFF], + "goldenrod" => [0xDA, 0xA5, 0x20, 0xFF], + "gray" => [0x80, 0x80, 0x80, 0xFF], + "green" => [0x00, 0x80, 0x00, 0xFF], + "greenyellow" => [0xAD, 0xFF, 0x2F, 0xFF], + "honeydew" => [0xF0, 0xFF, 0xF0, 0xFF], + "hotpink" => [0xFF, 0x69, 0xB4, 0xFF], + "indianred" => [0xCD, 0x5C, 0x5C, 0xFF], + "indigo" => [0x4B, 0x00, 0x82, 0xFF], + "ivory" => [0xFF, 0xFF, 0xF0, 0xFF], + "khaki" => [0xF0, 0xE6, 0x8C, 0xFF], + "lavender" => [0xE6, 0xE6, 0xFA, 0xFF], + "lavenderblush" => [0xFF, 0xF0, 0xF5, 0xFF], + "lawngreen" => [0x7C, 0xFC, 0x00, 0xFF], + "lemonchiffon" => [0xFF, 0xFA, 0xCD, 0xFF], + "lightblue" => [0xAD, 0xD8, 0xE6, 0xFF], + "lightcoral" => [0xF0, 0x80, 0x80, 0xFF], + "lightcyan" => [0xE0, 0xFF, 0xFF, 0xFF], + "lightgoldenrodyellow" => [0xFA, 0xFA, 0xD2, 0xFF], + "lightgray" => [0xD3, 0xD3, 0xD3, 0xFF], + "lightgreen" => [0x90, 0xEE, 0x90, 0xFF], + "lightpink" => [0xFF, 0xB6, 0xC1, 0xFF], + "lightsalmon" => [0xFF, 0xA0, 0x7A, 0xFF], + "lightseagreen" => [0x20, 0xB2, 0xAA, 0xFF], + "lightskyblue" => [0x87, 0xCE, 0xFA, 0xFF], + "lightslategray" => [0x77, 0x88, 0x99, 0xFF], + "lightsteelblue" => [0xB0, 0xC4, 0xDE, 0xFF], + "lightyellow" => [0xFF, 0xFF, 0xE0, 0xFF], + "lime" => [0x00, 0xFF, 0x00, 0xFF], + "limegreen" => [0x32, 0xCD, 0x32, 0xFF], + "linen" => [0xFA, 0xF0, 0xE6, 0xFF], + "maroon" => [0x80, 0x00, 0x00, 0xFF], + "mediumaquamarine" => [0x66, 0xCD, 0xAA, 0xFF], + "mediumblue" => [0x00, 0x00, 0xCD, 0xFF], + "mediumorchid" => [0xBA, 0x55, 0xD3, 0xFF], + "mediumpurple" => [0x93, 0x70, 0xDB, 0xFF], + "mediumseagreen" => [0x3C, 0xB3, 0x71, 0xFF], + "mediumslateblue" => [0x7B, 0x68, 0xEE, 0xFF], + "mediumspringgreen" => [0x00, 0xFA, 0x9A, 0xFF], + "mediumturquoise" => [0x48, 0xD1, 0xCC, 0xFF], + "mediumvioletred" => [0xC7, 0x15, 0x85, 0xFF], + "midnightblue" => [0x19, 0x19, 0x70, 0xFF], + "mintcream" => [0xF5, 0xFF, 0xFA, 0xFF], + "mistyrose" => [0xFF, 0xE4, 0xE1, 0xFF], + "moccasin" => [0xFF, 0xE4, 0xB5, 0xFF], + "navajowhite" => [0xFF, 0xDE, 0xAD, 0xFF], + "navy" => [0x00, 0x00, 0x80, 0xFF], + "oldlace" => [0xFD, 0xF5, 0xE6, 0xFF], + "olive" => [0x80, 0x80, 0x00, 0xFF], + "olivedrab" => [0x6B, 0x8E, 0x23, 0xFF], + "orange" => [0xFF, 0xA5, 0x00, 0xFF], + "orangered" => [0xFF, 0x45, 0x00, 0xFF], + "orchid" => [0xDA, 0x70, 0xD6, 0xFF], + "palegoldenrod" => [0xEE, 0xE8, 0xAA, 0xFF], + "palegreen" => [0x98, 0xFB, 0x98, 0xFF], + "paleturquoise" => [0xAF, 0xEE, 0xEE, 0xFF], + "palevioletred" => [0xDB, 0x70, 0x93, 0xFF], + "papayawhip" => [0xFF, 0xEF, 0xD5, 0xFF], + "peachpuff" => [0xFF, 0xDA, 0xB9, 0xFF], + "peru" => [0xCD, 0x85, 0x3F, 0xFF], + "pink" => [0xFF, 0xC0, 0xCB, 0xFF], + "plum" => [0xDD, 0xA0, 0xDD, 0xFF], + "powderblue" => [0xB0, 0xE0, 0xE6, 0xFF], + "purple" => [0x80, 0x00, 0x80, 0xFF], + "rebeccapurple" => [0x66, 0x33, 0x99, 0xFF], + "red" => [0xFF, 0x00, 0x00, 0xFF], + "rosybrown" => [0xBC, 0x8F, 0x8F, 0xFF], + "royalblue" => [0x41, 0x69, 0xE1, 0xFF], + "saddlebrown" => [0x8B, 0x45, 0x13, 0xFF], + "salmon" => [0xFA, 0x80, 0x72, 0xFF], + "sandybrown" => [0xF4, 0xA4, 0x60, 0xFF], + "seagreen" => [0x2E, 0x8B, 0x57, 0xFF], + "seashell" => [0xFF, 0xF5, 0xEE, 0xFF], + "sienna" => [0xA0, 0x52, 0x2D, 0xFF], + "silver" => [0xC0, 0xC0, 0xC0, 0xFF], + "skyblue" => [0x87, 0xCE, 0xEB, 0xFF], + "slateblue" => [0x6A, 0x5A, 0xCD, 0xFF], + "slategray" => [0x70, 0x80, 0x90, 0xFF], + "snow" => [0xFF, 0xFA, 0xFA, 0xFF], + "springgreen" => [0x00, 0xFF, 0x7F, 0xFF], + "steelblue" => [0x46, 0x82, 0xB4, 0xFF], + "tan" => [0xD2, 0xB4, 0x8C, 0xFF], + "teal" => [0x00, 0x80, 0x80, 0xFF], + "thistle" => [0xD8, 0xBF, 0xD8, 0xFF], + "tomato" => [0xFF, 0x63, 0x47, 0xFF], + "turquoise" => [0x40, 0xE0, 0xD0, 0xFF], + "violet" => [0xEE, 0x82, 0xEE, 0xFF], + "wheat" => [0xF5, 0xDE, 0xB3, 0xFF], + "white" => [0xFF, 0xFF, 0xFF, 0xFF], + "whitesmoke" => [0xF5, 0xF5, 0xF5, 0xFF], + "yellow" => [0xFF, 0xFF, 0x00, 0xFF], + "yellowgreen" => [0x9A, 0xCD, 0x32, 0xFF], + "transparent" => [0x00, 0x00, 0x00, 0x00], + }, + rgba_to_name: phf::phf_map! { + [0xF0, 0xF8, 0xFF, 0xFF] => "aliceblue", + [0xFA, 0xEB, 0xD7, 0xFF] => "antiquewhite", + [0x00, 0xFF, 0xFF, 0xFF] => "aqua", + [0x7F, 0xFF, 0xD4, 0xFF] => "aquamarine", + [0xF0, 0xFF, 0xFF, 0xFF] => "azure", + [0xF5, 0xF5, 0xDC, 0xFF] => "beige", + [0xFF, 0xE4, 0xC4, 0xFF] => "bisque", + [0x00, 0x00, 0x00, 0xFF] => "black", + [0xFF, 0xEB, 0xCD, 0xFF] => "blanchedalmond", + [0x00, 0x00, 0xFF, 0xFF] => "blue", + [0x8A, 0x2B, 0xE2, 0xFF] => "blueviolet", + [0xA5, 0x2A, 0x2A, 0xFF] => "brown", + [0xDE, 0xB8, 0x87, 0xFF] => "burlywood", + [0x5F, 0x9E, 0xA0, 0xFF] => "cadetblue", + [0x7F, 0xFF, 0x00, 0xFF] => "chartreuse", + [0xD2, 0x69, 0x1E, 0xFF] => "chocolate", + [0xFF, 0x7F, 0x50, 0xFF] => "coral", + [0x64, 0x95, 0xED, 0xFF] => "cornflowerblue", + [0xFF, 0xF8, 0xDC, 0xFF] => "cornsilk", + [0xDC, 0x14, 0x3C, 0xFF] => "crimson", + [0x00, 0x00, 0x8B, 0xFF] => "darkblue", + [0x00, 0x8B, 0x8B, 0xFF] => "darkcyan", + [0xB8, 0x86, 0x0B, 0xFF] => "darkgoldenrod", + [0xA9, 0xA9, 0xA9, 0xFF] => "darkgray", + [0x00, 0x64, 0x00, 0xFF] => "darkgreen", + [0xBD, 0xB7, 0x6B, 0xFF] => "darkkhaki", + [0x8B, 0x00, 0x8B, 0xFF] => "darkmagenta", + [0x55, 0x6B, 0x2F, 0xFF] => "darkolivegreen", + [0xFF, 0x8C, 0x00, 0xFF] => "darkorange", + [0x99, 0x32, 0xCC, 0xFF] => "darkorchid", + [0x8B, 0x00, 0x00, 0xFF] => "darkred", + [0xE9, 0x96, 0x7A, 0xFF] => "darksalmon", + [0x8F, 0xBC, 0x8F, 0xFF] => "darkseagreen", + [0x48, 0x3D, 0x8B, 0xFF] => "darkslateblue", + [0x2F, 0x4F, 0x4F, 0xFF] => "darkslategray", + [0x00, 0xCE, 0xD1, 0xFF] => "darkturquoise", + [0x94, 0x00, 0xD3, 0xFF] => "darkviolet", + [0xFF, 0x14, 0x93, 0xFF] => "deeppink", + [0x00, 0xBF, 0xFF, 0xFF] => "deepskyblue", + [0x69, 0x69, 0x69, 0xFF] => "dimgray", + [0x1E, 0x90, 0xFF, 0xFF] => "dodgerblue", + [0xB2, 0x22, 0x22, 0xFF] => "firebrick", + [0xFF, 0xFA, 0xF0, 0xFF] => "floralwhite", + [0x22, 0x8B, 0x22, 0xFF] => "forestgreen", + [0xFF, 0x00, 0xFF, 0xFF] => "fuchsia", + [0xDC, 0xDC, 0xDC, 0xFF] => "gainsboro", + [0xF8, 0xF8, 0xFF, 0xFF] => "ghostwhite", + [0xFF, 0xD7, 0x00, 0xFF] => "gold", + [0xDA, 0xA5, 0x20, 0xFF] => "goldenrod", + [0x80, 0x80, 0x80, 0xFF] => "gray", + [0x00, 0x80, 0x00, 0xFF] => "green", + [0xAD, 0xFF, 0x2F, 0xFF] => "greenyellow", + [0xF0, 0xFF, 0xF0, 0xFF] => "honeydew", + [0xFF, 0x69, 0xB4, 0xFF] => "hotpink", + [0xCD, 0x5C, 0x5C, 0xFF] => "indianred", + [0x4B, 0x00, 0x82, 0xFF] => "indigo", + [0xFF, 0xFF, 0xF0, 0xFF] => "ivory", + [0xF0, 0xE6, 0x8C, 0xFF] => "khaki", + [0xE6, 0xE6, 0xFA, 0xFF] => "lavender", + [0xFF, 0xF0, 0xF5, 0xFF] => "lavenderblush", + [0x7C, 0xFC, 0x00, 0xFF] => "lawngreen", + [0xFF, 0xFA, 0xCD, 0xFF] => "lemonchiffon", + [0xAD, 0xD8, 0xE6, 0xFF] => "lightblue", + [0xF0, 0x80, 0x80, 0xFF] => "lightcoral", + [0xE0, 0xFF, 0xFF, 0xFF] => "lightcyan", + [0xFA, 0xFA, 0xD2, 0xFF] => "lightgoldenrodyellow", + [0xD3, 0xD3, 0xD3, 0xFF] => "lightgray", + [0x90, 0xEE, 0x90, 0xFF] => "lightgreen", + [0xFF, 0xB6, 0xC1, 0xFF] => "lightpink", + [0xFF, 0xA0, 0x7A, 0xFF] => "lightsalmon", + [0x20, 0xB2, 0xAA, 0xFF] => "lightseagreen", + [0x87, 0xCE, 0xFA, 0xFF] => "lightskyblue", + [0x77, 0x88, 0x99, 0xFF] => "lightslategray", + [0xB0, 0xC4, 0xDE, 0xFF] => "lightsteelblue", + [0xFF, 0xFF, 0xE0, 0xFF] => "lightyellow", + [0x00, 0xFF, 0x00, 0xFF] => "lime", + [0x32, 0xCD, 0x32, 0xFF] => "limegreen", + [0xFA, 0xF0, 0xE6, 0xFF] => "linen", + [0x80, 0x00, 0x00, 0xFF] => "maroon", + [0x66, 0xCD, 0xAA, 0xFF] => "mediumaquamarine", + [0x00, 0x00, 0xCD, 0xFF] => "mediumblue", + [0xBA, 0x55, 0xD3, 0xFF] => "mediumorchid", + [0x93, 0x70, 0xDB, 0xFF] => "mediumpurple", + [0x3C, 0xB3, 0x71, 0xFF] => "mediumseagreen", + [0x7B, 0x68, 0xEE, 0xFF] => "mediumslateblue", + [0x00, 0xFA, 0x9A, 0xFF] => "mediumspringgreen", + [0x48, 0xD1, 0xCC, 0xFF] => "mediumturquoise", + [0xC7, 0x15, 0x85, 0xFF] => "mediumvioletred", + [0x19, 0x19, 0x70, 0xFF] => "midnightblue", + [0xF5, 0xFF, 0xFA, 0xFF] => "mintcream", + [0xFF, 0xE4, 0xE1, 0xFF] => "mistyrose", + [0xFF, 0xE4, 0xB5, 0xFF] => "moccasin", + [0xFF, 0xDE, 0xAD, 0xFF] => "navajowhite", + [0x00, 0x00, 0x80, 0xFF] => "navy", + [0xFD, 0xF5, 0xE6, 0xFF] => "oldlace", + [0x80, 0x80, 0x00, 0xFF] => "olive", + [0x6B, 0x8E, 0x23, 0xFF] => "olivedrab", + [0xFF, 0xA5, 0x00, 0xFF] => "orange", + [0xFF, 0x45, 0x00, 0xFF] => "orangered", + [0xDA, 0x70, 0xD6, 0xFF] => "orchid", + [0xEE, 0xE8, 0xAA, 0xFF] => "palegoldenrod", + [0x98, 0xFB, 0x98, 0xFF] => "palegreen", + [0xAF, 0xEE, 0xEE, 0xFF] => "paleturquoise", + [0xDB, 0x70, 0x93, 0xFF] => "palevioletred", + [0xFF, 0xEF, 0xD5, 0xFF] => "papayawhip", + [0xFF, 0xDA, 0xB9, 0xFF] => "peachpuff", + [0xCD, 0x85, 0x3F, 0xFF] => "peru", + [0xFF, 0xC0, 0xCB, 0xFF] => "pink", + [0xDD, 0xA0, 0xDD, 0xFF] => "plum", + [0xB0, 0xE0, 0xE6, 0xFF] => "powderblue", + [0x80, 0x00, 0x80, 0xFF] => "purple", + [0x66, 0x33, 0x99, 0xFF] => "rebeccapurple", + [0xFF, 0x00, 0x00, 0xFF] => "red", + [0xBC, 0x8F, 0x8F, 0xFF] => "rosybrown", + [0x41, 0x69, 0xE1, 0xFF] => "royalblue", + [0x8B, 0x45, 0x13, 0xFF] => "saddlebrown", + [0xFA, 0x80, 0x72, 0xFF] => "salmon", + [0xF4, 0xA4, 0x60, 0xFF] => "sandybrown", + [0x2E, 0x8B, 0x57, 0xFF] => "seagreen", + [0xFF, 0xF5, 0xEE, 0xFF] => "seashell", + [0xA0, 0x52, 0x2D, 0xFF] => "sienna", + [0xC0, 0xC0, 0xC0, 0xFF] => "silver", + [0x87, 0xCE, 0xEB, 0xFF] => "skyblue", + [0x6A, 0x5A, 0xCD, 0xFF] => "slateblue", + [0x70, 0x80, 0x90, 0xFF] => "slategray", + [0xFF, 0xFA, 0xFA, 0xFF] => "snow", + [0x00, 0xFF, 0x7F, 0xFF] => "springgreen", + [0x46, 0x82, 0xB4, 0xFF] => "steelblue", + [0xD2, 0xB4, 0x8C, 0xFF] => "tan", + [0x00, 0x80, 0x80, 0xFF] => "teal", + [0xD8, 0xBF, 0xD8, 0xFF] => "thistle", + [0xFF, 0x63, 0x47, 0xFF] => "tomato", + [0x40, 0xE0, 0xD0, 0xFF] => "turquoise", + [0xEE, 0x82, 0xEE, 0xFF] => "violet", + [0xF5, 0xDE, 0xB3, 0xFF] => "wheat", + [0xFF, 0xFF, 0xFF, 0xFF] => "white", + [0xF5, 0xF5, 0xF5, 0xFF] => "whitesmoke", + [0xFF, 0xFF, 0x00, 0xFF] => "yellow", + [0x9A, 0xCD, 0x32, 0xFF] => "yellowgreen", + [0x00, 0x00, 0x00, 0x00] => "transparent", + }, +};