Merge branch 'master' of https://github.com/connorskees/grass into modules
This commit is contained in:
commit
28701b2707
@ -60,6 +60,7 @@ codemap = "0.1.3"
|
|||||||
peekmore = "0.5.2"
|
peekmore = "0.5.2"
|
||||||
wasm-bindgen = { version = "0.2.65", optional = true }
|
wasm-bindgen = { version = "0.2.65", optional = true }
|
||||||
beef = "0.4.4"
|
beef = "0.4.4"
|
||||||
|
phf = { version = "0.8.0", features = ["macros"] }
|
||||||
# criterion is not a dev-dependency because it makes tests take too
|
# criterion is not a dev-dependency because it makes tests take too
|
||||||
# long to compile, and you cannot make dev-dependencies optional
|
# long to compile, and you cannot make dev-dependencies optional
|
||||||
criterion = { version = "0.3.3", optional = true }
|
criterion = { version = "0.3.3", optional = true }
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use grass::StyleSheet;
|
|
||||||
|
|
||||||
pub fn many_hsla(c: &mut Criterion) {
|
pub fn many_hsla(c: &mut Criterion) {
|
||||||
c.bench_function("many_hsla", |b| {
|
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) {
|
pub fn many_named_colors(c: &mut Criterion) {
|
||||||
c.bench_function("many_named_colors", |b| {
|
c.bench_function("many_named_colors", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
StyleSheet::new(black_box(
|
grass::from_string(
|
||||||
include_str!("many_named_colors.scss").to_string(),
|
black_box(include_str!("many_named_colors.scss").to_string()),
|
||||||
))
|
&Default::default(),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ fn repr(red: &Number, green: &Number, blue: &Number, alpha: &Number) -> String {
|
|||||||
|
|
||||||
if alpha < &Number::one() {
|
if alpha < &Number::one() {
|
||||||
format!("rgba({}, {}, {}, {})", red_u8, green_u8, blue_u8, alpha)
|
format!("rgba({}, {}, {}, {})", red_u8, green_u8, blue_u8, alpha)
|
||||||
} else if let Some(c) = NAMED_COLORS.get_by_rgba([red_u8, green_u8, blue_u8, 0xFF]) {
|
} else if let Some(c) = NAMED_COLORS.get_by_rgba([red_u8, green_u8, blue_u8]) {
|
||||||
(*c).to_string()
|
(*c).to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("#{:0>2x}{:0>2x}{:0>2x}", red_u8, green_u8, blue_u8)
|
format!("#{:0>2x}{:0>2x}{:0>2x}", red_u8, green_u8, blue_u8)
|
||||||
|
@ -1,177 +1,305 @@
|
|||||||
//! A big dictionary of named colors and their
|
//! A big dictionary of named colors and their
|
||||||
//! corresponding RGBA values
|
//! corresponding RGBA values
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub(crate) struct NamedColorMap {
|
pub(crate) struct NamedColorMap {
|
||||||
name_to_rgba: HashMap<&'static str, [u8; 4]>,
|
name_to_rgba: phf::Map<&'static str, [u8; 4]>,
|
||||||
rgba_to_name: HashMap<[u8; 4], &'static str>,
|
rgba_to_name: phf::Map<[u8; 3], &'static str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NamedColorMap {
|
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]> {
|
pub fn get_by_name(&self, name: &str) -> Option<&[u8; 4]> {
|
||||||
self.name_to_rgba.get(name)
|
self.name_to_rgba.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_by_rgba(&self, rgba: [u8; 4]) -> Option<&&str> {
|
// transparent is not handled
|
||||||
|
pub fn get_by_rgba(&self, rgba: [u8; 3]) -> Option<&&str> {
|
||||||
self.rgba_to_name.get(&rgba)
|
self.rgba_to_name.get(&rgba)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) static NAMED_COLORS: Lazy<NamedColorMap> = Lazy::new(|| {
|
// Adding one color requires adding to both map due to limitation in phf crate.
|
||||||
let mut m = NamedColorMap::with_capacity(150);
|
pub(crate) static NAMED_COLORS: NamedColorMap = NamedColorMap {
|
||||||
m.insert("aliceblue", [0xF0, 0xF8, 0xFF, 0xFF]);
|
name_to_rgba: phf::phf_map! {
|
||||||
m.insert("antiquewhite", [0xFA, 0xEB, 0xD7, 0xFF]);
|
"aliceblue" => [0xF0, 0xF8, 0xFF, 0xFF],
|
||||||
m.insert("aqua", [0x00, 0xFF, 0xFF, 0xFF]);
|
"antiquewhite" => [0xFA, 0xEB, 0xD7, 0xFF],
|
||||||
m.insert("aquamarine", [0x7F, 0xFF, 0xD4, 0xFF]);
|
"aqua" => [0x00, 0xFF, 0xFF, 0xFF],
|
||||||
m.insert("azure", [0xF0, 0xFF, 0xFF, 0xFF]);
|
"aquamarine" => [0x7F, 0xFF, 0xD4, 0xFF],
|
||||||
m.insert("beige", [0xF5, 0xF5, 0xDC, 0xFF]);
|
"azure" => [0xF0, 0xFF, 0xFF, 0xFF],
|
||||||
m.insert("bisque", [0xFF, 0xE4, 0xC4, 0xFF]);
|
"beige" => [0xF5, 0xF5, 0xDC, 0xFF],
|
||||||
m.insert("black", [0x00, 0x00, 0x00, 0xFF]);
|
"bisque" => [0xFF, 0xE4, 0xC4, 0xFF],
|
||||||
m.insert("blanchedalmond", [0xFF, 0xEB, 0xCD, 0xFF]);
|
"black" => [0x00, 0x00, 0x00, 0xFF],
|
||||||
m.insert("blue", [0x00, 0x00, 0xFF, 0xFF]);
|
"blanchedalmond" => [0xFF, 0xEB, 0xCD, 0xFF],
|
||||||
m.insert("blueviolet", [0x8A, 0x2B, 0xE2, 0xFF]);
|
"blue" => [0x00, 0x00, 0xFF, 0xFF],
|
||||||
m.insert("brown", [0xA5, 0x2A, 0x2A, 0xFF]);
|
"blueviolet" => [0x8A, 0x2B, 0xE2, 0xFF],
|
||||||
m.insert("burlywood", [0xDE, 0xB8, 0x87, 0xFF]);
|
"brown" => [0xA5, 0x2A, 0x2A, 0xFF],
|
||||||
m.insert("cadetblue", [0x5F, 0x9E, 0xA0, 0xFF]);
|
"burlywood" => [0xDE, 0xB8, 0x87, 0xFF],
|
||||||
m.insert("chartreuse", [0x7F, 0xFF, 0x00, 0xFF]);
|
"cadetblue" => [0x5F, 0x9E, 0xA0, 0xFF],
|
||||||
m.insert("chocolate", [0xD2, 0x69, 0x1E, 0xFF]);
|
"chartreuse" => [0x7F, 0xFF, 0x00, 0xFF],
|
||||||
m.insert("coral", [0xFF, 0x7F, 0x50, 0xFF]);
|
"chocolate" => [0xD2, 0x69, 0x1E, 0xFF],
|
||||||
m.insert("cornflowerblue", [0x64, 0x95, 0xED, 0xFF]);
|
"coral" => [0xFF, 0x7F, 0x50, 0xFF],
|
||||||
m.insert("cornsilk", [0xFF, 0xF8, 0xDC, 0xFF]);
|
"cornflowerblue" => [0x64, 0x95, 0xED, 0xFF],
|
||||||
m.insert("crimson", [0xDC, 0x14, 0x3C, 0xFF]);
|
"cornsilk" => [0xFF, 0xF8, 0xDC, 0xFF],
|
||||||
m.insert("darkblue", [0x00, 0x00, 0x8B, 0xFF]);
|
"crimson" => [0xDC, 0x14, 0x3C, 0xFF],
|
||||||
m.insert("darkcyan", [0x00, 0x8B, 0x8B, 0xFF]);
|
"darkblue" => [0x00, 0x00, 0x8B, 0xFF],
|
||||||
m.insert("darkgoldenrod", [0xB8, 0x86, 0x0B, 0xFF]);
|
"darkcyan" => [0x00, 0x8B, 0x8B, 0xFF],
|
||||||
m.insert("darkgray", [0xA9, 0xA9, 0xA9, 0xFF]);
|
"darkgoldenrod" => [0xB8, 0x86, 0x0B, 0xFF],
|
||||||
m.insert("darkgreen", [0x00, 0x64, 0x00, 0xFF]);
|
"darkgray" => [0xA9, 0xA9, 0xA9, 0xFF],
|
||||||
m.insert("darkkhaki", [0xBD, 0xB7, 0x6B, 0xFF]);
|
"darkgreen" => [0x00, 0x64, 0x00, 0xFF],
|
||||||
m.insert("darkmagenta", [0x8B, 0x00, 0x8B, 0xFF]);
|
"darkkhaki" => [0xBD, 0xB7, 0x6B, 0xFF],
|
||||||
m.insert("darkolivegreen", [0x55, 0x6B, 0x2F, 0xFF]);
|
"darkmagenta" => [0x8B, 0x00, 0x8B, 0xFF],
|
||||||
m.insert("darkorange", [0xFF, 0x8C, 0x00, 0xFF]);
|
"darkolivegreen" => [0x55, 0x6B, 0x2F, 0xFF],
|
||||||
m.insert("darkorchid", [0x99, 0x32, 0xCC, 0xFF]);
|
"darkorange" => [0xFF, 0x8C, 0x00, 0xFF],
|
||||||
m.insert("darkred", [0x8B, 0x00, 0x00, 0xFF]);
|
"darkorchid" => [0x99, 0x32, 0xCC, 0xFF],
|
||||||
m.insert("darksalmon", [0xE9, 0x96, 0x7A, 0xFF]);
|
"darkred" => [0x8B, 0x00, 0x00, 0xFF],
|
||||||
m.insert("darkseagreen", [0x8F, 0xBC, 0x8F, 0xFF]);
|
"darksalmon" => [0xE9, 0x96, 0x7A, 0xFF],
|
||||||
m.insert("darkslateblue", [0x48, 0x3D, 0x8B, 0xFF]);
|
"darkseagreen" => [0x8F, 0xBC, 0x8F, 0xFF],
|
||||||
m.insert("darkslategray", [0x2F, 0x4F, 0x4F, 0xFF]);
|
"darkslateblue" => [0x48, 0x3D, 0x8B, 0xFF],
|
||||||
m.insert("darkturquoise", [0x00, 0xCE, 0xD1, 0xFF]);
|
"darkslategray" => [0x2F, 0x4F, 0x4F, 0xFF],
|
||||||
m.insert("darkviolet", [0x94, 0x00, 0xD3, 0xFF]);
|
"darkturquoise" => [0x00, 0xCE, 0xD1, 0xFF],
|
||||||
m.insert("deeppink", [0xFF, 0x14, 0x93, 0xFF]);
|
"darkviolet" => [0x94, 0x00, 0xD3, 0xFF],
|
||||||
m.insert("deepskyblue", [0x00, 0xBF, 0xFF, 0xFF]);
|
"deeppink" => [0xFF, 0x14, 0x93, 0xFF],
|
||||||
m.insert("dimgray", [0x69, 0x69, 0x69, 0xFF]);
|
"deepskyblue" => [0x00, 0xBF, 0xFF, 0xFF],
|
||||||
m.insert("dodgerblue", [0x1E, 0x90, 0xFF, 0xFF]);
|
"dimgray" => [0x69, 0x69, 0x69, 0xFF],
|
||||||
m.insert("firebrick", [0xB2, 0x22, 0x22, 0xFF]);
|
"dodgerblue" => [0x1E, 0x90, 0xFF, 0xFF],
|
||||||
m.insert("floralwhite", [0xFF, 0xFA, 0xF0, 0xFF]);
|
"firebrick" => [0xB2, 0x22, 0x22, 0xFF],
|
||||||
m.insert("forestgreen", [0x22, 0x8B, 0x22, 0xFF]);
|
"floralwhite" => [0xFF, 0xFA, 0xF0, 0xFF],
|
||||||
m.insert("fuchsia", [0xFF, 0x00, 0xFF, 0xFF]);
|
"forestgreen" => [0x22, 0x8B, 0x22, 0xFF],
|
||||||
m.insert("gainsboro", [0xDC, 0xDC, 0xDC, 0xFF]);
|
"fuchsia" => [0xFF, 0x00, 0xFF, 0xFF],
|
||||||
m.insert("ghostwhite", [0xF8, 0xF8, 0xFF, 0xFF]);
|
"gainsboro" => [0xDC, 0xDC, 0xDC, 0xFF],
|
||||||
m.insert("gold", [0xFF, 0xD7, 0x00, 0xFF]);
|
"ghostwhite" => [0xF8, 0xF8, 0xFF, 0xFF],
|
||||||
m.insert("goldenrod", [0xDA, 0xA5, 0x20, 0xFF]);
|
"gold" => [0xFF, 0xD7, 0x00, 0xFF],
|
||||||
m.insert("gray", [0x80, 0x80, 0x80, 0xFF]);
|
"goldenrod" => [0xDA, 0xA5, 0x20, 0xFF],
|
||||||
m.insert("green", [0x00, 0x80, 0x00, 0xFF]);
|
"gray" => [0x80, 0x80, 0x80, 0xFF],
|
||||||
m.insert("greenyellow", [0xAD, 0xFF, 0x2F, 0xFF]);
|
"green" => [0x00, 0x80, 0x00, 0xFF],
|
||||||
m.insert("honeydew", [0xF0, 0xFF, 0xF0, 0xFF]);
|
"greenyellow" => [0xAD, 0xFF, 0x2F, 0xFF],
|
||||||
m.insert("hotpink", [0xFF, 0x69, 0xB4, 0xFF]);
|
"honeydew" => [0xF0, 0xFF, 0xF0, 0xFF],
|
||||||
m.insert("indianred", [0xCD, 0x5C, 0x5C, 0xFF]);
|
"hotpink" => [0xFF, 0x69, 0xB4, 0xFF],
|
||||||
m.insert("indigo", [0x4B, 0x00, 0x82, 0xFF]);
|
"indianred" => [0xCD, 0x5C, 0x5C, 0xFF],
|
||||||
m.insert("ivory", [0xFF, 0xFF, 0xF0, 0xFF]);
|
"indigo" => [0x4B, 0x00, 0x82, 0xFF],
|
||||||
m.insert("khaki", [0xF0, 0xE6, 0x8C, 0xFF]);
|
"ivory" => [0xFF, 0xFF, 0xF0, 0xFF],
|
||||||
m.insert("lavender", [0xE6, 0xE6, 0xFA, 0xFF]);
|
"khaki" => [0xF0, 0xE6, 0x8C, 0xFF],
|
||||||
m.insert("lavenderblush", [0xFF, 0xF0, 0xF5, 0xFF]);
|
"lavender" => [0xE6, 0xE6, 0xFA, 0xFF],
|
||||||
m.insert("lawngreen", [0x7C, 0xFC, 0x00, 0xFF]);
|
"lavenderblush" => [0xFF, 0xF0, 0xF5, 0xFF],
|
||||||
m.insert("lemonchiffon", [0xFF, 0xFA, 0xCD, 0xFF]);
|
"lawngreen" => [0x7C, 0xFC, 0x00, 0xFF],
|
||||||
m.insert("lightblue", [0xAD, 0xD8, 0xE6, 0xFF]);
|
"lemonchiffon" => [0xFF, 0xFA, 0xCD, 0xFF],
|
||||||
m.insert("lightcoral", [0xF0, 0x80, 0x80, 0xFF]);
|
"lightblue" => [0xAD, 0xD8, 0xE6, 0xFF],
|
||||||
m.insert("lightcyan", [0xE0, 0xFF, 0xFF, 0xFF]);
|
"lightcoral" => [0xF0, 0x80, 0x80, 0xFF],
|
||||||
m.insert("lightgoldenrodyellow", [0xFA, 0xFA, 0xD2, 0xFF]);
|
"lightcyan" => [0xE0, 0xFF, 0xFF, 0xFF],
|
||||||
m.insert("lightgray", [0xD3, 0xD3, 0xD3, 0xFF]);
|
"lightgoldenrodyellow" => [0xFA, 0xFA, 0xD2, 0xFF],
|
||||||
m.insert("lightgreen", [0x90, 0xEE, 0x90, 0xFF]);
|
"lightgray" => [0xD3, 0xD3, 0xD3, 0xFF],
|
||||||
m.insert("lightpink", [0xFF, 0xB6, 0xC1, 0xFF]);
|
"lightgreen" => [0x90, 0xEE, 0x90, 0xFF],
|
||||||
m.insert("lightsalmon", [0xFF, 0xA0, 0x7A, 0xFF]);
|
"lightpink" => [0xFF, 0xB6, 0xC1, 0xFF],
|
||||||
m.insert("lightseagreen", [0x20, 0xB2, 0xAA, 0xFF]);
|
"lightsalmon" => [0xFF, 0xA0, 0x7A, 0xFF],
|
||||||
m.insert("lightskyblue", [0x87, 0xCE, 0xFA, 0xFF]);
|
"lightseagreen" => [0x20, 0xB2, 0xAA, 0xFF],
|
||||||
m.insert("lightslategray", [0x77, 0x88, 0x99, 0xFF]);
|
"lightskyblue" => [0x87, 0xCE, 0xFA, 0xFF],
|
||||||
m.insert("lightsteelblue", [0xB0, 0xC4, 0xDE, 0xFF]);
|
"lightslategray" => [0x77, 0x88, 0x99, 0xFF],
|
||||||
m.insert("lightyellow", [0xFF, 0xFF, 0xE0, 0xFF]);
|
"lightsteelblue" => [0xB0, 0xC4, 0xDE, 0xFF],
|
||||||
m.insert("lime", [0x00, 0xFF, 0x00, 0xFF]);
|
"lightyellow" => [0xFF, 0xFF, 0xE0, 0xFF],
|
||||||
m.insert("limegreen", [0x32, 0xCD, 0x32, 0xFF]);
|
"lime" => [0x00, 0xFF, 0x00, 0xFF],
|
||||||
m.insert("linen", [0xFA, 0xF0, 0xE6, 0xFF]);
|
"limegreen" => [0x32, 0xCD, 0x32, 0xFF],
|
||||||
m.insert("maroon", [0x80, 0x00, 0x00, 0xFF]);
|
"linen" => [0xFA, 0xF0, 0xE6, 0xFF],
|
||||||
m.insert("mediumaquamarine", [0x66, 0xCD, 0xAA, 0xFF]);
|
"maroon" => [0x80, 0x00, 0x00, 0xFF],
|
||||||
m.insert("mediumblue", [0x00, 0x00, 0xCD, 0xFF]);
|
"mediumaquamarine" => [0x66, 0xCD, 0xAA, 0xFF],
|
||||||
m.insert("mediumorchid", [0xBA, 0x55, 0xD3, 0xFF]);
|
"mediumblue" => [0x00, 0x00, 0xCD, 0xFF],
|
||||||
m.insert("mediumpurple", [0x93, 0x70, 0xDB, 0xFF]);
|
"mediumorchid" => [0xBA, 0x55, 0xD3, 0xFF],
|
||||||
m.insert("mediumseagreen", [0x3C, 0xB3, 0x71, 0xFF]);
|
"mediumpurple" => [0x93, 0x70, 0xDB, 0xFF],
|
||||||
m.insert("mediumslateblue", [0x7B, 0x68, 0xEE, 0xFF]);
|
"mediumseagreen" => [0x3C, 0xB3, 0x71, 0xFF],
|
||||||
m.insert("mediumspringgreen", [0x00, 0xFA, 0x9A, 0xFF]);
|
"mediumslateblue" => [0x7B, 0x68, 0xEE, 0xFF],
|
||||||
m.insert("mediumturquoise", [0x48, 0xD1, 0xCC, 0xFF]);
|
"mediumspringgreen" => [0x00, 0xFA, 0x9A, 0xFF],
|
||||||
m.insert("mediumvioletred", [0xC7, 0x15, 0x85, 0xFF]);
|
"mediumturquoise" => [0x48, 0xD1, 0xCC, 0xFF],
|
||||||
m.insert("midnightblue", [0x19, 0x19, 0x70, 0xFF]);
|
"mediumvioletred" => [0xC7, 0x15, 0x85, 0xFF],
|
||||||
m.insert("mintcream", [0xF5, 0xFF, 0xFA, 0xFF]);
|
"midnightblue" => [0x19, 0x19, 0x70, 0xFF],
|
||||||
m.insert("mistyrose", [0xFF, 0xE4, 0xE1, 0xFF]);
|
"mintcream" => [0xF5, 0xFF, 0xFA, 0xFF],
|
||||||
m.insert("moccasin", [0xFF, 0xE4, 0xB5, 0xFF]);
|
"mistyrose" => [0xFF, 0xE4, 0xE1, 0xFF],
|
||||||
m.insert("navajowhite", [0xFF, 0xDE, 0xAD, 0xFF]);
|
"moccasin" => [0xFF, 0xE4, 0xB5, 0xFF],
|
||||||
m.insert("navy", [0x00, 0x00, 0x80, 0xFF]);
|
"navajowhite" => [0xFF, 0xDE, 0xAD, 0xFF],
|
||||||
m.insert("oldlace", [0xFD, 0xF5, 0xE6, 0xFF]);
|
"navy" => [0x00, 0x00, 0x80, 0xFF],
|
||||||
m.insert("olive", [0x80, 0x80, 0x00, 0xFF]);
|
"oldlace" => [0xFD, 0xF5, 0xE6, 0xFF],
|
||||||
m.insert("olivedrab", [0x6B, 0x8E, 0x23, 0xFF]);
|
"olive" => [0x80, 0x80, 0x00, 0xFF],
|
||||||
m.insert("orange", [0xFF, 0xA5, 0x00, 0xFF]);
|
"olivedrab" => [0x6B, 0x8E, 0x23, 0xFF],
|
||||||
m.insert("orangered", [0xFF, 0x45, 0x00, 0xFF]);
|
"orange" => [0xFF, 0xA5, 0x00, 0xFF],
|
||||||
m.insert("orchid", [0xDA, 0x70, 0xD6, 0xFF]);
|
"orangered" => [0xFF, 0x45, 0x00, 0xFF],
|
||||||
m.insert("palegoldenrod", [0xEE, 0xE8, 0xAA, 0xFF]);
|
"orchid" => [0xDA, 0x70, 0xD6, 0xFF],
|
||||||
m.insert("palegreen", [0x98, 0xFB, 0x98, 0xFF]);
|
"palegoldenrod" => [0xEE, 0xE8, 0xAA, 0xFF],
|
||||||
m.insert("paleturquoise", [0xAF, 0xEE, 0xEE, 0xFF]);
|
"palegreen" => [0x98, 0xFB, 0x98, 0xFF],
|
||||||
m.insert("palevioletred", [0xDB, 0x70, 0x93, 0xFF]);
|
"paleturquoise" => [0xAF, 0xEE, 0xEE, 0xFF],
|
||||||
m.insert("papayawhip", [0xFF, 0xEF, 0xD5, 0xFF]);
|
"palevioletred" => [0xDB, 0x70, 0x93, 0xFF],
|
||||||
m.insert("peachpuff", [0xFF, 0xDA, 0xB9, 0xFF]);
|
"papayawhip" => [0xFF, 0xEF, 0xD5, 0xFF],
|
||||||
m.insert("peru", [0xCD, 0x85, 0x3F, 0xFF]);
|
"peachpuff" => [0xFF, 0xDA, 0xB9, 0xFF],
|
||||||
m.insert("pink", [0xFF, 0xC0, 0xCB, 0xFF]);
|
"peru" => [0xCD, 0x85, 0x3F, 0xFF],
|
||||||
m.insert("plum", [0xDD, 0xA0, 0xDD, 0xFF]);
|
"pink" => [0xFF, 0xC0, 0xCB, 0xFF],
|
||||||
m.insert("powderblue", [0xB0, 0xE0, 0xE6, 0xFF]);
|
"plum" => [0xDD, 0xA0, 0xDD, 0xFF],
|
||||||
m.insert("purple", [0x80, 0x00, 0x80, 0xFF]);
|
"powderblue" => [0xB0, 0xE0, 0xE6, 0xFF],
|
||||||
m.insert("rebeccapurple", [0x66, 0x33, 0x99, 0xFF]);
|
"purple" => [0x80, 0x00, 0x80, 0xFF],
|
||||||
m.insert("red", [0xFF, 0x00, 0x00, 0xFF]);
|
"rebeccapurple" => [0x66, 0x33, 0x99, 0xFF],
|
||||||
m.insert("rosybrown", [0xBC, 0x8F, 0x8F, 0xFF]);
|
"red" => [0xFF, 0x00, 0x00, 0xFF],
|
||||||
m.insert("royalblue", [0x41, 0x69, 0xE1, 0xFF]);
|
"rosybrown" => [0xBC, 0x8F, 0x8F, 0xFF],
|
||||||
m.insert("saddlebrown", [0x8B, 0x45, 0x13, 0xFF]);
|
"royalblue" => [0x41, 0x69, 0xE1, 0xFF],
|
||||||
m.insert("salmon", [0xFA, 0x80, 0x72, 0xFF]);
|
"saddlebrown" => [0x8B, 0x45, 0x13, 0xFF],
|
||||||
m.insert("sandybrown", [0xF4, 0xA4, 0x60, 0xFF]);
|
"salmon" => [0xFA, 0x80, 0x72, 0xFF],
|
||||||
m.insert("seagreen", [0x2E, 0x8B, 0x57, 0xFF]);
|
"sandybrown" => [0xF4, 0xA4, 0x60, 0xFF],
|
||||||
m.insert("seashell", [0xFF, 0xF5, 0xEE, 0xFF]);
|
"seagreen" => [0x2E, 0x8B, 0x57, 0xFF],
|
||||||
m.insert("sienna", [0xA0, 0x52, 0x2D, 0xFF]);
|
"seashell" => [0xFF, 0xF5, 0xEE, 0xFF],
|
||||||
m.insert("silver", [0xC0, 0xC0, 0xC0, 0xFF]);
|
"sienna" => [0xA0, 0x52, 0x2D, 0xFF],
|
||||||
m.insert("skyblue", [0x87, 0xCE, 0xEB, 0xFF]);
|
"silver" => [0xC0, 0xC0, 0xC0, 0xFF],
|
||||||
m.insert("slateblue", [0x6A, 0x5A, 0xCD, 0xFF]);
|
"skyblue" => [0x87, 0xCE, 0xEB, 0xFF],
|
||||||
m.insert("slategray", [0x70, 0x80, 0x90, 0xFF]);
|
"slateblue" => [0x6A, 0x5A, 0xCD, 0xFF],
|
||||||
m.insert("snow", [0xFF, 0xFA, 0xFA, 0xFF]);
|
"slategray" => [0x70, 0x80, 0x90, 0xFF],
|
||||||
m.insert("springgreen", [0x00, 0xFF, 0x7F, 0xFF]);
|
"snow" => [0xFF, 0xFA, 0xFA, 0xFF],
|
||||||
m.insert("steelblue", [0x46, 0x82, 0xB4, 0xFF]);
|
"springgreen" => [0x00, 0xFF, 0x7F, 0xFF],
|
||||||
m.insert("tan", [0xD2, 0xB4, 0x8C, 0xFF]);
|
"steelblue" => [0x46, 0x82, 0xB4, 0xFF],
|
||||||
m.insert("teal", [0x00, 0x80, 0x80, 0xFF]);
|
"tan" => [0xD2, 0xB4, 0x8C, 0xFF],
|
||||||
m.insert("thistle", [0xD8, 0xBF, 0xD8, 0xFF]);
|
"teal" => [0x00, 0x80, 0x80, 0xFF],
|
||||||
m.insert("tomato", [0xFF, 0x63, 0x47, 0xFF]);
|
"thistle" => [0xD8, 0xBF, 0xD8, 0xFF],
|
||||||
m.insert("turquoise", [0x40, 0xE0, 0xD0, 0xFF]);
|
"tomato" => [0xFF, 0x63, 0x47, 0xFF],
|
||||||
m.insert("violet", [0xEE, 0x82, 0xEE, 0xFF]);
|
"turquoise" => [0x40, 0xE0, 0xD0, 0xFF],
|
||||||
m.insert("wheat", [0xF5, 0xDE, 0xB3, 0xFF]);
|
"violet" => [0xEE, 0x82, 0xEE, 0xFF],
|
||||||
m.insert("white", [0xFF, 0xFF, 0xFF, 0xFF]);
|
"wheat" => [0xF5, 0xDE, 0xB3, 0xFF],
|
||||||
m.insert("whitesmoke", [0xF5, 0xF5, 0xF5, 0xFF]);
|
"white" => [0xFF, 0xFF, 0xFF, 0xFF],
|
||||||
m.insert("yellow", [0xFF, 0xFF, 0x00, 0xFF]);
|
"whitesmoke" => [0xF5, 0xF5, 0xF5, 0xFF],
|
||||||
m.insert("yellowgreen", [0x9A, 0xCD, 0x32, 0xFF]);
|
"yellow" => [0xFF, 0xFF, 0x00, 0xFF],
|
||||||
m.insert("transparent", [0x00, 0x00, 0x00, 0x00]);
|
"yellowgreen" => [0x9A, 0xCD, 0x32, 0xFF],
|
||||||
m
|
"transparent" => [0x00, 0x00, 0x00, 0x00],
|
||||||
});
|
},
|
||||||
|
rgba_to_name: phf::phf_map! {
|
||||||
|
[0xF0, 0xF8, 0xFF] => "aliceblue",
|
||||||
|
[0xFA, 0xEB, 0xD7] => "antiquewhite",
|
||||||
|
[0x00, 0xFF, 0xFF] => "aqua",
|
||||||
|
[0x7F, 0xFF, 0xD4] => "aquamarine",
|
||||||
|
[0xF0, 0xFF, 0xFF] => "azure",
|
||||||
|
[0xF5, 0xF5, 0xDC] => "beige",
|
||||||
|
[0xFF, 0xE4, 0xC4] => "bisque",
|
||||||
|
[0x00, 0x00, 0x00] => "black",
|
||||||
|
[0xFF, 0xEB, 0xCD] => "blanchedalmond",
|
||||||
|
[0x00, 0x00, 0xFF] => "blue",
|
||||||
|
[0x8A, 0x2B, 0xE2] => "blueviolet",
|
||||||
|
[0xA5, 0x2A, 0x2A] => "brown",
|
||||||
|
[0xDE, 0xB8, 0x87] => "burlywood",
|
||||||
|
[0x5F, 0x9E, 0xA0] => "cadetblue",
|
||||||
|
[0x7F, 0xFF, 0x00] => "chartreuse",
|
||||||
|
[0xD2, 0x69, 0x1E] => "chocolate",
|
||||||
|
[0xFF, 0x7F, 0x50] => "coral",
|
||||||
|
[0x64, 0x95, 0xED] => "cornflowerblue",
|
||||||
|
[0xFF, 0xF8, 0xDC] => "cornsilk",
|
||||||
|
[0xDC, 0x14, 0x3C] => "crimson",
|
||||||
|
[0x00, 0x00, 0x8B] => "darkblue",
|
||||||
|
[0x00, 0x8B, 0x8B] => "darkcyan",
|
||||||
|
[0xB8, 0x86, 0x0B] => "darkgoldenrod",
|
||||||
|
[0xA9, 0xA9, 0xA9] => "darkgray",
|
||||||
|
[0x00, 0x64, 0x00] => "darkgreen",
|
||||||
|
[0xBD, 0xB7, 0x6B] => "darkkhaki",
|
||||||
|
[0x8B, 0x00, 0x8B] => "darkmagenta",
|
||||||
|
[0x55, 0x6B, 0x2F] => "darkolivegreen",
|
||||||
|
[0xFF, 0x8C, 0x00] => "darkorange",
|
||||||
|
[0x99, 0x32, 0xCC] => "darkorchid",
|
||||||
|
[0x8B, 0x00, 0x00] => "darkred",
|
||||||
|
[0xE9, 0x96, 0x7A] => "darksalmon",
|
||||||
|
[0x8F, 0xBC, 0x8F] => "darkseagreen",
|
||||||
|
[0x48, 0x3D, 0x8B] => "darkslateblue",
|
||||||
|
[0x2F, 0x4F, 0x4F] => "darkslategray",
|
||||||
|
[0x00, 0xCE, 0xD1] => "darkturquoise",
|
||||||
|
[0x94, 0x00, 0xD3] => "darkviolet",
|
||||||
|
[0xFF, 0x14, 0x93] => "deeppink",
|
||||||
|
[0x00, 0xBF, 0xFF] => "deepskyblue",
|
||||||
|
[0x69, 0x69, 0x69] => "dimgray",
|
||||||
|
[0x1E, 0x90, 0xFF] => "dodgerblue",
|
||||||
|
[0xB2, 0x22, 0x22] => "firebrick",
|
||||||
|
[0xFF, 0xFA, 0xF0] => "floralwhite",
|
||||||
|
[0x22, 0x8B, 0x22] => "forestgreen",
|
||||||
|
[0xFF, 0x00, 0xFF] => "fuchsia",
|
||||||
|
[0xDC, 0xDC, 0xDC] => "gainsboro",
|
||||||
|
[0xF8, 0xF8, 0xFF] => "ghostwhite",
|
||||||
|
[0xFF, 0xD7, 0x00] => "gold",
|
||||||
|
[0xDA, 0xA5, 0x20] => "goldenrod",
|
||||||
|
[0x80, 0x80, 0x80] => "gray",
|
||||||
|
[0x00, 0x80, 0x00] => "green",
|
||||||
|
[0xAD, 0xFF, 0x2F] => "greenyellow",
|
||||||
|
[0xF0, 0xFF, 0xF0] => "honeydew",
|
||||||
|
[0xFF, 0x69, 0xB4] => "hotpink",
|
||||||
|
[0xCD, 0x5C, 0x5C] => "indianred",
|
||||||
|
[0x4B, 0x00, 0x82] => "indigo",
|
||||||
|
[0xFF, 0xFF, 0xF0] => "ivory",
|
||||||
|
[0xF0, 0xE6, 0x8C] => "khaki",
|
||||||
|
[0xE6, 0xE6, 0xFA] => "lavender",
|
||||||
|
[0xFF, 0xF0, 0xF5] => "lavenderblush",
|
||||||
|
[0x7C, 0xFC, 0x00] => "lawngreen",
|
||||||
|
[0xFF, 0xFA, 0xCD] => "lemonchiffon",
|
||||||
|
[0xAD, 0xD8, 0xE6] => "lightblue",
|
||||||
|
[0xF0, 0x80, 0x80] => "lightcoral",
|
||||||
|
[0xE0, 0xFF, 0xFF] => "lightcyan",
|
||||||
|
[0xFA, 0xFA, 0xD2] => "lightgoldenrodyellow",
|
||||||
|
[0xD3, 0xD3, 0xD3] => "lightgray",
|
||||||
|
[0x90, 0xEE, 0x90] => "lightgreen",
|
||||||
|
[0xFF, 0xB6, 0xC1] => "lightpink",
|
||||||
|
[0xFF, 0xA0, 0x7A] => "lightsalmon",
|
||||||
|
[0x20, 0xB2, 0xAA] => "lightseagreen",
|
||||||
|
[0x87, 0xCE, 0xFA] => "lightskyblue",
|
||||||
|
[0x77, 0x88, 0x99] => "lightslategray",
|
||||||
|
[0xB0, 0xC4, 0xDE] => "lightsteelblue",
|
||||||
|
[0xFF, 0xFF, 0xE0] => "lightyellow",
|
||||||
|
[0x00, 0xFF, 0x00] => "lime",
|
||||||
|
[0x32, 0xCD, 0x32] => "limegreen",
|
||||||
|
[0xFA, 0xF0, 0xE6] => "linen",
|
||||||
|
[0x80, 0x00, 0x00] => "maroon",
|
||||||
|
[0x66, 0xCD, 0xAA] => "mediumaquamarine",
|
||||||
|
[0x00, 0x00, 0xCD] => "mediumblue",
|
||||||
|
[0xBA, 0x55, 0xD3] => "mediumorchid",
|
||||||
|
[0x93, 0x70, 0xDB] => "mediumpurple",
|
||||||
|
[0x3C, 0xB3, 0x71] => "mediumseagreen",
|
||||||
|
[0x7B, 0x68, 0xEE] => "mediumslateblue",
|
||||||
|
[0x00, 0xFA, 0x9A] => "mediumspringgreen",
|
||||||
|
[0x48, 0xD1, 0xCC] => "mediumturquoise",
|
||||||
|
[0xC7, 0x15, 0x85] => "mediumvioletred",
|
||||||
|
[0x19, 0x19, 0x70] => "midnightblue",
|
||||||
|
[0xF5, 0xFF, 0xFA] => "mintcream",
|
||||||
|
[0xFF, 0xE4, 0xE1] => "mistyrose",
|
||||||
|
[0xFF, 0xE4, 0xB5] => "moccasin",
|
||||||
|
[0xFF, 0xDE, 0xAD] => "navajowhite",
|
||||||
|
[0x00, 0x00, 0x80] => "navy",
|
||||||
|
[0xFD, 0xF5, 0xE6] => "oldlace",
|
||||||
|
[0x80, 0x80, 0x00] => "olive",
|
||||||
|
[0x6B, 0x8E, 0x23] => "olivedrab",
|
||||||
|
[0xFF, 0xA5, 0x00] => "orange",
|
||||||
|
[0xFF, 0x45, 0x00] => "orangered",
|
||||||
|
[0xDA, 0x70, 0xD6] => "orchid",
|
||||||
|
[0xEE, 0xE8, 0xAA] => "palegoldenrod",
|
||||||
|
[0x98, 0xFB, 0x98] => "palegreen",
|
||||||
|
[0xAF, 0xEE, 0xEE] => "paleturquoise",
|
||||||
|
[0xDB, 0x70, 0x93] => "palevioletred",
|
||||||
|
[0xFF, 0xEF, 0xD5] => "papayawhip",
|
||||||
|
[0xFF, 0xDA, 0xB9] => "peachpuff",
|
||||||
|
[0xCD, 0x85, 0x3F] => "peru",
|
||||||
|
[0xFF, 0xC0, 0xCB] => "pink",
|
||||||
|
[0xDD, 0xA0, 0xDD] => "plum",
|
||||||
|
[0xB0, 0xE0, 0xE6] => "powderblue",
|
||||||
|
[0x80, 0x00, 0x80] => "purple",
|
||||||
|
[0x66, 0x33, 0x99] => "rebeccapurple",
|
||||||
|
[0xFF, 0x00, 0x00] => "red",
|
||||||
|
[0xBC, 0x8F, 0x8F] => "rosybrown",
|
||||||
|
[0x41, 0x69, 0xE1] => "royalblue",
|
||||||
|
[0x8B, 0x45, 0x13] => "saddlebrown",
|
||||||
|
[0xFA, 0x80, 0x72] => "salmon",
|
||||||
|
[0xF4, 0xA4, 0x60] => "sandybrown",
|
||||||
|
[0x2E, 0x8B, 0x57] => "seagreen",
|
||||||
|
[0xFF, 0xF5, 0xEE] => "seashell",
|
||||||
|
[0xA0, 0x52, 0x2D] => "sienna",
|
||||||
|
[0xC0, 0xC0, 0xC0] => "silver",
|
||||||
|
[0x87, 0xCE, 0xEB] => "skyblue",
|
||||||
|
[0x6A, 0x5A, 0xCD] => "slateblue",
|
||||||
|
[0x70, 0x80, 0x90] => "slategray",
|
||||||
|
[0xFF, 0xFA, 0xFA] => "snow",
|
||||||
|
[0x00, 0xFF, 0x7F] => "springgreen",
|
||||||
|
[0x46, 0x82, 0xB4] => "steelblue",
|
||||||
|
[0xD2, 0xB4, 0x8C] => "tan",
|
||||||
|
[0x00, 0x80, 0x80] => "teal",
|
||||||
|
[0xD8, 0xBF, 0xD8] => "thistle",
|
||||||
|
[0xFF, 0x63, 0x47] => "tomato",
|
||||||
|
[0x40, 0xE0, 0xD0] => "turquoise",
|
||||||
|
[0xEE, 0x82, 0xEE] => "violet",
|
||||||
|
[0xF5, 0xDE, 0xB3] => "wheat",
|
||||||
|
[0xFF, 0xFF, 0xFF] => "white",
|
||||||
|
[0xF5, 0xF5, 0xF5] => "whitesmoke",
|
||||||
|
[0xFF, 0xFF, 0x00] => "yellow",
|
||||||
|
[0x9A, 0xCD, 0x32] => "yellowgreen",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
@ -150,7 +150,7 @@ pub struct Options<'a> {
|
|||||||
quiet: bool,
|
quiet: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for Options<'a> {
|
impl Default for Options<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -379,27 +379,24 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for named colors
|
// check for named colors
|
||||||
if let Some(c) = NAMED_COLORS.get_by_name(lower.as_str()) {
|
Ok(if let Some(c) = NAMED_COLORS.get_by_name(lower.as_str()) {
|
||||||
return Ok(
|
IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Color(Box::new(
|
||||||
IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Color(Box::new(
|
Color::new(c[0], c[1], c[2], c[3], s),
|
||||||
Color::new(c[0], c[1], c[2], c[3], s),
|
))))
|
||||||
))))
|
} else {
|
||||||
.span(span),
|
// check for keywords
|
||||||
);
|
match s.as_str() {
|
||||||
}
|
"true" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::True)),
|
||||||
|
"false" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::False)),
|
||||||
// check for keywords
|
"null" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Null)),
|
||||||
Ok(match s.as_str() {
|
"not" => IntermediateValue::Op(Op::Not),
|
||||||
"true" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::True)),
|
"and" => IntermediateValue::Op(Op::And),
|
||||||
"false" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::False)),
|
"or" => IntermediateValue::Op(Op::Or),
|
||||||
"null" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Null)),
|
_ => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::String(
|
||||||
"not" => IntermediateValue::Op(Op::Not),
|
s,
|
||||||
"and" => IntermediateValue::Op(Op::And),
|
QuoteKind::None,
|
||||||
"or" => IntermediateValue::Op(Op::Or),
|
))),
|
||||||
_ => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::String(
|
}
|
||||||
s,
|
|
||||||
QuoteKind::None,
|
|
||||||
))),
|
|
||||||
}
|
}
|
||||||
.span(span))
|
.span(span))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user