Refactor colors

This commit is contained in:
ConnorSkees 2020-02-03 16:44:07 -05:00
parent 6607101d4d
commit d9339a68b5
2 changed files with 513 additions and 0 deletions

44
src/color/mod.rs Normal file
View File

@ -0,0 +1,44 @@
use std::fmt::{self, Display};
use name::ColorName;
mod name;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub(crate) struct Color {
red: u16,
green: u16,
blue: u16,
alpha: u16,
repr: ColorRepr,
}
impl Display for Color {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.repr {
ColorRepr::Name(n) => write!(f, "{}", n),
ColorRepr::Hex3 => todo!(), //write!(f, "#{}{}{}", self.red, self.green, self.blue),
ColorRepr::Hex6 => write!(f, "#{:X}{:X}{:X}", self.red, self.green, self.blue),
ColorRepr::Hex8 => write!(
f,
"#{:X}{:X}{:X}{:X}",
self.red, self.green, self.blue, self.alpha
),
ColorRepr::Function if self.alpha < 1 => write!(
f,
"rgba({}, {}, {}, {})",
self.red, self.green, self.blue, self.alpha
),
ColorRepr::Function => write!(f, "#{:X}{:X}{:X}", self.red, self.green, self.blue),
}
}
}
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
enum ColorRepr {
Name(ColorName),
Hex3,
Hex6,
Hex8,
Function,
}

469
src/color/name.rs Normal file
View File

@ -0,0 +1,469 @@
use std::convert::TryFrom;
use std::fmt::{self, Display};
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub(crate) enum ColorName {
AliceBlue, // = 0xF0F8FF,
AntiqueWhite, // = 0xFAEBD7,
Aqua, // = 0x00FFFF,
Aquamarine, // = 0x7FFFD4,
Azure, // = 0xF0FFFF,
Beige, // = 0xF5F5DC,
Bisque, // = 0xFFE4C4,
Black, // = 0x000000,
BlanchedAlmond, // = 0xFFEBCD,
Blue, // = 0x0000FF,
BlueViolet, // = 0x8A2BE2,
Brown, // = 0xA52A2A,
BurlyWood, // = 0xDEB887,
CadetBlue, // = 0x5F9EA0,
Chartreuse, // = 0x7FFF00,
Chocolate, // = 0xD2691E,
Coral, // = 0xFF7F50,
CornflowerBlue, // = 0x6495ED,
Cornsilk, // = 0xFFF8DC,
Crimson, // = 0xDC143C,
Cyan, // = 0x00FFFF
DarkBlue, // = 0x00008B,
DarkCyan, // = 0x008B8B,
DarkGoldenRod, // = 0xB8860B,
DarkGray, // = 0xA9A9A9,
DarkGrey, // = 0xA9A9A9
DarkGreen, // = 0x006400,
DarkKhaki, // = 0xBDB76B,
DarkMagenta, // = 0x8B008B,
DarkOliveGreen, // = 0x556B2F,
DarkOrange, // = 0xFF8C00,
DarkOrchid, // = 0x9932CC,
DarkRed, // = 0x8B0000,
DarkSalmon, // = 0xE9967A,
DarkSeaGreen, // = 0x8FBC8F,
DarkSlateBlue, // = 0x483D8B,
DarkSlateGray, // = 0x2F4F4F,
DarkSlateGrey, // = 0x2F4F4F
DarkTurquoise, // = 0x00CED1,
DarkViolet, // = 0x9400D3,
DeepPink, // = 0xFF1493,
DeepSkyBlue, // = 0x00BFFF,
DimGray, // = 0x696969,
DimGrey, // = 0x696969
DodgerBlue, // = 0x1E90FF,
FireBrick, // = 0xB22222,
FloralWhite, // = 0xFFFAF0,
ForestGreen, // = 0x228B22,
Fuchsia, // = 0xFF00FF,
Gainsboro, // = 0xDCDCDC,
GhostWhite, // = 0xF8F8FF,
Gold, // = 0xFFD700,
GoldenRod, // = 0xDAA520,
Gray, // = 0x808080,
Grey, // = 0x808080
Green, // = 0x008000,
GreenYellow, // = 0xADFF2F,
HoneyDew, // = 0xF0FFF0,
HotPink, // = 0xFF69B4,
IndianRed, // = 0xCD5C5C,
Indigo, // = 0x4B0082,
Ivory, // = 0xFFFFF0,
Khaki, // = 0xF0E68C,
Lavender, // = 0xE6E6FA,
LavenderBlush, // = 0xFFF0F5,
LawnGreen, // = 0x7CFC00,
LemonChiffon, // = 0xFFFACD,
LightBlue, // = 0xADD8E6,
LightCoral, // = 0xF08080,
LightCyan, // = 0xE0FFFF,
LightGoldenRodYellow, // = 0xFAFAD2,
LightGray, // = 0xD3D3D3,
LightGrey, // = 0xD3D3D3
LightGreen, // = 0x90EE90,
LightPink, // = 0xFFB6C1,
LightSalmon, // = 0xFFA07A,
LightSeaGreen, // = 0x20B2AA,
LightSkyBlue, // = 0x87CEFA,
LightSlateGray, // = 0x778899,
LightSlateGrey, // = 0x778899
LightSteelBlue, // = 0xB0C4DE,
LightYellow, // = 0xFFFFE0,
Lime, // = 0x00FF00,
LimeGreen, // = 0x32CD32,
Linen, // = 0xFAF0E6,
Magenta, // = 0xFF00FF
Maroon, // = 0x800000,
MediumAquaMarine, // = 0x66CDAA,
MediumBlue, // = 0x0000CD,
MediumOrchid, // = 0xBA55D3,
MediumPurple, // = 0x9370DB,
MediumSeaGreen, // = 0x3CB371,
MediumSlateBlue, // = 0x7B68EE,
MediumSpringGreen, // = 0x00FA9A,
MediumTurquoise, // = 0x48D1CC,
MediumVioletRed, // = 0xC71585,
MidnightBlue, // = 0x191970,
MintCream, // = 0xF5FFFA,
MistyRose, // = 0xFFE4E1,
Moccasin, // = 0xFFE4B5,
NavajoWhite, // = 0xFFDEAD,
Navy, // = 0x000080,
OldLace, // = 0xFDF5E6,
Olive, // = 0x808000,
OliveDrab, // = 0x6B8E23,
Orange, // = 0xFFA500,
OrangeRed, // = 0xFF4500,
Orchid, // = 0xDA70D6,
PaleGoldenRod, // = 0xEEE8AA,
PaleGreen, // = 0x98FB98,
PaleTurquoise, // = 0xAFEEEE,
PaleVioletRed, // = 0xDB7093,
PapayaWhip, // = 0xFFEFD5,
PeachPuff, // = 0xFFDAB9,
Peru, // = 0xCD853F,
Pink, // = 0xFFC0CB,
Plum, // = 0xDDA0DD,
PowderBlue, // = 0xB0E0E6,
Purple, // = 0x800080,
RebeccaPurple, // = 0x663399,
Red, // = 0xFF0000,
RosyBrown, // = 0xBC8F8F,
RoyalBlue, // = 0x4169E1,
SaddleBrown, // = 0x8B4513,
Salmon, // = 0xFA8072,
SandyBrown, // = 0xF4A460,
SeaGreen, // = 0x2E8B57,
SeaShell, // = 0xFFF5EE,
Sienna, // = 0xA0522D,
Silver, // = 0xC0C0C0,
SkyBlue, // = 0x87CEEB,
SlateBlue, // = 0x6A5ACD,
SlateGray, // = 0x708090,
SlateGrey, // = 0x708090
Snow, // = 0xFFFAFA,
SpringGreen, // = 0x00FF7F,
SteelBlue, // = 0x4682B4,
Tan, // = 0xD2B48C,
Teal, // = 0x008080,
Thistle, // = 0xD8BFD8,
Tomato, // = 0xFF6347,
Turquoise, // = 0x40E0D0,
Violet, // = 0xEE82EE,
Wheat, // = 0xF5DEB3,
White, // = 0xFFFFFF,
WhiteSmoke, // = 0xF5F5F5,
Yellow, // = 0xFFFF00,
YellowGreen, // = 0x9ACD32,
}
impl Display for ColorName {
#[allow(clippy::match_same_arms, clippy::many_single_char_names)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// I want them all to be on separate lines so doing things with regex or multiple cursors is easier
match self {
Self::AliceBlue => write!(f, "aliceblue"),
Self::AntiqueWhite => write!(f, "antiquewhite"),
Self::Aqua => write!(f, "aqua"),
Self::Aquamarine => write!(f, "aquamarine"),
Self::Azure => write!(f, "azure"),
Self::Beige => write!(f, "beige"),
Self::Bisque => write!(f, "bisque"),
Self::Black => write!(f, "black"),
Self::BlanchedAlmond => write!(f, "blanchedalmond"),
Self::Blue => write!(f, "blue"),
Self::BlueViolet => write!(f, "blueviolet"),
Self::Brown => write!(f, "brown"),
Self::BurlyWood => write!(f, "burlywood"),
Self::CadetBlue => write!(f, "cadetblue"),
Self::Chartreuse => write!(f, "chartreuse"),
Self::Chocolate => write!(f, "chocolate"),
Self::Coral => write!(f, "coral"),
Self::CornflowerBlue => write!(f, "cornflowerblue"),
Self::Cornsilk => write!(f, "cornsilk"),
Self::Crimson => write!(f, "crimson"),
Self::Cyan => write!(f, "cyan"),
Self::DarkBlue => write!(f, "darkblue"),
Self::DarkCyan => write!(f, "darkcyan"),
Self::DarkGoldenRod => write!(f, "darkgoldenrod"),
Self::DarkGray => write!(f, "darkgray"),
Self::DarkGrey => write!(f, "darkgrey"),
Self::DarkGreen => write!(f, "darkgreen"),
Self::DarkKhaki => write!(f, "darkkhaki"),
Self::DarkMagenta => write!(f, "darkmagenta"),
Self::DarkOliveGreen => write!(f, "darkolivegreen"),
Self::DarkOrange => write!(f, "darkorange"),
Self::DarkOrchid => write!(f, "darkorchid"),
Self::DarkRed => write!(f, "darkred"),
Self::DarkSalmon => write!(f, "darksalmon"),
Self::DarkSeaGreen => write!(f, "darkseagreen"),
Self::DarkSlateBlue => write!(f, "darkslateblue"),
Self::DarkSlateGray => write!(f, "darkslategray"),
Self::DarkSlateGrey => write!(f, "darkslategrey"),
Self::DarkTurquoise => write!(f, "darkturquoise"),
Self::DarkViolet => write!(f, "darkviolet"),
Self::DeepPink => write!(f, "deeppink"),
Self::DeepSkyBlue => write!(f, "deepskyblue"),
Self::DimGray => write!(f, "dimgray"),
Self::DimGrey => write!(f, "dimgrey"),
Self::DodgerBlue => write!(f, "dodgerblue"),
Self::FireBrick => write!(f, "firebrick"),
Self::FloralWhite => write!(f, "floralwhite"),
Self::ForestGreen => write!(f, "forestgreen"),
Self::Fuchsia => write!(f, "fuchsia"),
Self::Gainsboro => write!(f, "gainsboro"),
Self::GhostWhite => write!(f, "ghostwhite"),
Self::Gold => write!(f, "gold"),
Self::GoldenRod => write!(f, "goldenrod"),
Self::Gray => write!(f, "gray"),
Self::Grey => write!(f, "grey"),
Self::Green => write!(f, "green"),
Self::GreenYellow => write!(f, "greenyellow"),
Self::HoneyDew => write!(f, "honeydew"),
Self::HotPink => write!(f, "hotpink"),
Self::IndianRed => write!(f, "indianred"),
Self::Indigo => write!(f, "indigo"),
Self::Ivory => write!(f, "ivory"),
Self::Khaki => write!(f, "khaki"),
Self::Lavender => write!(f, "lavender"),
Self::LavenderBlush => write!(f, "lavenderblush"),
Self::LawnGreen => write!(f, "lawngreen"),
Self::LemonChiffon => write!(f, "lemonchiffon"),
Self::LightBlue => write!(f, "lightblue"),
Self::LightCoral => write!(f, "lightcoral"),
Self::LightCyan => write!(f, "lightcyan"),
Self::LightGoldenRodYellow => write!(f, "lightgoldenrodyellow"),
Self::LightGray => write!(f, "lightgray"),
Self::LightGrey => write!(f, "lightgrey"),
Self::LightGreen => write!(f, "lightgreen"),
Self::LightPink => write!(f, "lightpink"),
Self::LightSalmon => write!(f, "lightsalmon"),
Self::LightSeaGreen => write!(f, "lightseagreen"),
Self::LightSkyBlue => write!(f, "lightskyblue"),
Self::LightSlateGray => write!(f, "lightslategray"),
Self::LightSlateGrey => write!(f, "lightslategrey"),
Self::LightSteelBlue => write!(f, "lightsteelblue"),
Self::LightYellow => write!(f, "lightyellow"),
Self::Lime => write!(f, "lime"),
Self::LimeGreen => write!(f, "limegreen"),
Self::Linen => write!(f, "linen"),
Self::Magenta => write!(f, "magenta"),
Self::Maroon => write!(f, "maroon"),
Self::MediumAquaMarine => write!(f, "mediumaquamarine"),
Self::MediumBlue => write!(f, "mediumblue"),
Self::MediumOrchid => write!(f, "mediumorchid"),
Self::MediumPurple => write!(f, "mediumpurple"),
Self::MediumSeaGreen => write!(f, "mediumseagreen"),
Self::MediumSlateBlue => write!(f, "mediumslateblue"),
Self::MediumSpringGreen => write!(f, "mediumspringgreen"),
Self::MediumTurquoise => write!(f, "mediumturquoise"),
Self::MediumVioletRed => write!(f, "mediumvioletred"),
Self::MidnightBlue => write!(f, "midnightblue"),
Self::MintCream => write!(f, "mintcream"),
Self::MistyRose => write!(f, "mistyrose"),
Self::Moccasin => write!(f, "moccasin"),
Self::NavajoWhite => write!(f, "navajowhite"),
Self::Navy => write!(f, "navy"),
Self::OldLace => write!(f, "oldlace"),
Self::Olive => write!(f, "olive"),
Self::OliveDrab => write!(f, "olivedrab"),
Self::Orange => write!(f, "orange"),
Self::OrangeRed => write!(f, "orangered"),
Self::Orchid => write!(f, "orchid"),
Self::PaleGoldenRod => write!(f, "palegoldenrod"),
Self::PaleGreen => write!(f, "palegreen"),
Self::PaleTurquoise => write!(f, "paleturquoise"),
Self::PaleVioletRed => write!(f, "palevioletred"),
Self::PapayaWhip => write!(f, "papayawhip"),
Self::PeachPuff => write!(f, "peachpuff"),
Self::Peru => write!(f, "peru"),
Self::Pink => write!(f, "pink"),
Self::Plum => write!(f, "plum"),
Self::PowderBlue => write!(f, "powderblue"),
Self::Purple => write!(f, "purple"),
Self::RebeccaPurple => write!(f, "rebeccapurple"),
Self::Red => write!(f, "red"),
Self::RosyBrown => write!(f, "rosybrown"),
Self::RoyalBlue => write!(f, "royalblue"),
Self::SaddleBrown => write!(f, "saddlebrown"),
Self::Salmon => write!(f, "salmon"),
Self::SandyBrown => write!(f, "sandybrown"),
Self::SeaGreen => write!(f, "seagreen"),
Self::SeaShell => write!(f, "seashell"),
Self::Sienna => write!(f, "sienna"),
Self::Silver => write!(f, "silver"),
Self::SkyBlue => write!(f, "skyblue"),
Self::SlateBlue => write!(f, "slateblue"),
Self::SlateGray => write!(f, "slategray"),
Self::SlateGrey => write!(f, "slategrey"),
Self::Snow => write!(f, "snow"),
Self::SpringGreen => write!(f, "springgreen"),
Self::SteelBlue => write!(f, "steelblue"),
Self::Tan => write!(f, "tan"),
Self::Teal => write!(f, "teal"),
Self::Thistle => write!(f, "thistle"),
Self::Tomato => write!(f, "tomato"),
Self::Turquoise => write!(f, "turquoise"),
Self::Violet => write!(f, "violet"),
Self::Wheat => write!(f, "wheat"),
Self::White => write!(f, "white"),
Self::WhiteSmoke => write!(f, "whitesmoke"),
Self::Yellow => write!(f, "yellow"),
Self::YellowGreen => write!(f, "yellowgreen"),
}
}
}
impl TryFrom<&str> for ColorName {
type Error = &'static str;
fn try_from(string: &str) -> Result<Self, Self::Error> {
match string.to_ascii_lowercase().as_str() {
"aliceblue" => Ok(Self::AliceBlue),
"antiquewhite" => Ok(Self::AntiqueWhite),
"aqua" => Ok(Self::Aqua),
"aquamarine" => Ok(Self::Aquamarine),
"azure" => Ok(Self::Azure),
"beige" => Ok(Self::Beige),
"bisque" => Ok(Self::Bisque),
"black" => Ok(Self::Black),
"blanchedalmond" => Ok(Self::BlanchedAlmond),
"blue" => Ok(Self::Blue),
"blueviolet" => Ok(Self::BlueViolet),
"brown" => Ok(Self::Brown),
"burlywood" => Ok(Self::BurlyWood),
"cadetblue" => Ok(Self::CadetBlue),
"chartreuse" => Ok(Self::Chartreuse),
"chocolate" => Ok(Self::Chocolate),
"coral" => Ok(Self::Coral),
"cornflowerblue" => Ok(Self::CornflowerBlue),
"cornsilk" => Ok(Self::Cornsilk),
"crimson" => Ok(Self::Crimson),
"cyan" => Ok(Self::Cyan),
"darkblue" => Ok(Self::DarkBlue),
"darkcyan" => Ok(Self::DarkCyan),
"darkgoldenrod" => Ok(Self::DarkGoldenRod),
"darkgray" => Ok(Self::DarkGray),
"darkgrey" => Ok(Self::DarkGrey),
"darkgreen" => Ok(Self::DarkGreen),
"darkkhaki" => Ok(Self::DarkKhaki),
"darkmagenta" => Ok(Self::DarkMagenta),
"darkolivegreen" => Ok(Self::DarkOliveGreen),
"darkorange" => Ok(Self::DarkOrange),
"darkorchid" => Ok(Self::DarkOrchid),
"darkred" => Ok(Self::DarkRed),
"darksalmon" => Ok(Self::DarkSalmon),
"darkseagreen" => Ok(Self::DarkSeaGreen),
"darkslateblue" => Ok(Self::DarkSlateBlue),
"darkslategray" => Ok(Self::DarkSlateGray),
"darkslategrey" => Ok(Self::DarkSlateGrey),
"darkturquoise" => Ok(Self::DarkTurquoise),
"darkviolet" => Ok(Self::DarkViolet),
"deeppink" => Ok(Self::DeepPink),
"deepskyblue" => Ok(Self::DeepSkyBlue),
"dimgray" => Ok(Self::DimGray),
"dimgrey" => Ok(Self::DimGrey),
"dodgerblue" => Ok(Self::DodgerBlue),
"firebrick" => Ok(Self::FireBrick),
"floralwhite" => Ok(Self::FloralWhite),
"forestgreen" => Ok(Self::ForestGreen),
"fuchsia" => Ok(Self::Fuchsia),
"gainsboro" => Ok(Self::Gainsboro),
"ghostwhite" => Ok(Self::GhostWhite),
"gold" => Ok(Self::Gold),
"goldenrod" => Ok(Self::GoldenRod),
"gray" => Ok(Self::Gray),
"grey" => Ok(Self::Grey),
"green" => Ok(Self::Green),
"greenyellow" => Ok(Self::GreenYellow),
"honeydew" => Ok(Self::HoneyDew),
"hotpink" => Ok(Self::HotPink),
"indianred" => Ok(Self::IndianRed),
"indigo" => Ok(Self::Indigo),
"ivory" => Ok(Self::Ivory),
"khaki" => Ok(Self::Khaki),
"lavender" => Ok(Self::Lavender),
"lavenderblush" => Ok(Self::LavenderBlush),
"lawngreen" => Ok(Self::LawnGreen),
"lemonchiffon" => Ok(Self::LemonChiffon),
"lightblue" => Ok(Self::LightBlue),
"lightcoral" => Ok(Self::LightCoral),
"lightcyan" => Ok(Self::LightCyan),
"lightgoldenrodyellow" => Ok(Self::LightGoldenRodYellow),
"lightgray" => Ok(Self::LightGray),
"lightgrey" => Ok(Self::LightGrey),
"lightgreen" => Ok(Self::LightGreen),
"lightpink" => Ok(Self::LightPink),
"lightsalmon" => Ok(Self::LightSalmon),
"lightseagreen" => Ok(Self::LightSeaGreen),
"lightskyblue" => Ok(Self::LightSkyBlue),
"lightslategray" => Ok(Self::LightSlateGray),
"lightslategrey" => Ok(Self::LightSlateGrey),
"lightsteelblue" => Ok(Self::LightSteelBlue),
"lightyellow" => Ok(Self::LightYellow),
"lime" => Ok(Self::Lime),
"limegreen" => Ok(Self::LimeGreen),
"linen" => Ok(Self::Linen),
"magenta" => Ok(Self::Magenta),
"maroon" => Ok(Self::Maroon),
"mediumaquamarine" => Ok(Self::MediumAquaMarine),
"mediumblue" => Ok(Self::MediumBlue),
"mediumorchid" => Ok(Self::MediumOrchid),
"mediumpurple" => Ok(Self::MediumPurple),
"mediumseagreen" => Ok(Self::MediumSeaGreen),
"mediumslateblue" => Ok(Self::MediumSlateBlue),
"mediumspringgreen" => Ok(Self::MediumSpringGreen),
"mediumturquoise" => Ok(Self::MediumTurquoise),
"mediumvioletred" => Ok(Self::MediumVioletRed),
"midnightblue" => Ok(Self::MidnightBlue),
"mintcream" => Ok(Self::MintCream),
"mistyrose" => Ok(Self::MistyRose),
"moccasin" => Ok(Self::Moccasin),
"navajowhite" => Ok(Self::NavajoWhite),
"navy" => Ok(Self::Navy),
"oldlace" => Ok(Self::OldLace),
"olive" => Ok(Self::Olive),
"olivedrab" => Ok(Self::OliveDrab),
"orange" => Ok(Self::Orange),
"orangered" => Ok(Self::OrangeRed),
"orchid" => Ok(Self::Orchid),
"palegoldenrod" => Ok(Self::PaleGoldenRod),
"palegreen" => Ok(Self::PaleGreen),
"paleturquoise" => Ok(Self::PaleTurquoise),
"palevioletred" => Ok(Self::PaleVioletRed),
"papayawhip" => Ok(Self::PapayaWhip),
"peachpuff" => Ok(Self::PeachPuff),
"peru" => Ok(Self::Peru),
"pink" => Ok(Self::Pink),
"plum" => Ok(Self::Plum),
"powderblue" => Ok(Self::PowderBlue),
"purple" => Ok(Self::Purple),
"rebeccapurple" => Ok(Self::RebeccaPurple),
"red" => Ok(Self::Red),
"rosybrown" => Ok(Self::RosyBrown),
"royalblue" => Ok(Self::RoyalBlue),
"saddlebrown" => Ok(Self::SaddleBrown),
"salmon" => Ok(Self::Salmon),
"sandybrown" => Ok(Self::SandyBrown),
"seagreen" => Ok(Self::SeaGreen),
"seashell" => Ok(Self::SeaShell),
"sienna" => Ok(Self::Sienna),
"silver" => Ok(Self::Silver),
"skyblue" => Ok(Self::SkyBlue),
"slateblue" => Ok(Self::SlateBlue),
"slategray" => Ok(Self::SlateGray),
"slategrey" => Ok(Self::SlateGrey),
"snow" => Ok(Self::Snow),
"springgreen" => Ok(Self::SpringGreen),
"steelblue" => Ok(Self::SteelBlue),
"tan" => Ok(Self::Tan),
"teal" => Ok(Self::Teal),
"thistle" => Ok(Self::Thistle),
"tomato" => Ok(Self::Tomato),
"turquoise" => Ok(Self::Turquoise),
"violet" => Ok(Self::Violet),
"wheat" => Ok(Self::Wheat),
"white" => Ok(Self::White),
"whitesmoke" => Ok(Self::WhiteSmoke),
"yellow" => Ok(Self::Yellow),
"yellowgreen" => Ok(Self::YellowGreen),
_ => Err("invalid color"),
}
}
}