629 lines
24 KiB
Rust
629 lines
24 KiB
Rust
|
use std::str::FromStr;
|
||
|
|
||
|
pub enum Color {
|
||
|
AliceBlue,
|
||
|
AntiqueWhite,
|
||
|
Aqua,
|
||
|
Aquamarine,
|
||
|
Azure,
|
||
|
Beige,
|
||
|
Bisque,
|
||
|
Black,
|
||
|
BlanchedAlmond,
|
||
|
Blue,
|
||
|
BlueViolet,
|
||
|
Brown,
|
||
|
BurlyWood,
|
||
|
CadetBlue,
|
||
|
Chartreuse,
|
||
|
Chocolate,
|
||
|
Coral,
|
||
|
CornflowerBlue,
|
||
|
Cornsilk,
|
||
|
Crimson,
|
||
|
Cyan,
|
||
|
DarkBlue,
|
||
|
DarkCyan,
|
||
|
DarkGoldenRod,
|
||
|
DarkGray,
|
||
|
DarkGrey,
|
||
|
DarkGreen,
|
||
|
DarkKhaki,
|
||
|
DarkMagenta,
|
||
|
DarkOliveGreen,
|
||
|
DarkOrange,
|
||
|
DarkOrchid,
|
||
|
DarkRed,
|
||
|
DarkSalmon,
|
||
|
DarkSeaGreen,
|
||
|
DarkSlateBlue,
|
||
|
DarkSlateGray,
|
||
|
DarkSlateGrey,
|
||
|
DarkTurquoise,
|
||
|
DarkViolet,
|
||
|
DeepPink,
|
||
|
DeepSkyBlue,
|
||
|
DimGray,
|
||
|
DimGrey,
|
||
|
DodgerBlue,
|
||
|
FireBrick,
|
||
|
FloralWhite,
|
||
|
ForestGreen,
|
||
|
Fuchsia,
|
||
|
Gainsboro,
|
||
|
GhostWhite,
|
||
|
Gold,
|
||
|
GoldenRod,
|
||
|
Gray,
|
||
|
Grey,
|
||
|
Green,
|
||
|
GreenYellow,
|
||
|
HoneyDew,
|
||
|
HotPink,
|
||
|
IndianRed,
|
||
|
Indigo,
|
||
|
Ivory,
|
||
|
Khaki,
|
||
|
Lavender,
|
||
|
LavenderBlush,
|
||
|
LawnGreen,
|
||
|
LemonChiffon,
|
||
|
LightBlue,
|
||
|
LightCoral,
|
||
|
LightCyan,
|
||
|
LightGoldenRodYellow,
|
||
|
LightGray,
|
||
|
LightGrey,
|
||
|
LightGreen,
|
||
|
LightPink,
|
||
|
LightSalmon,
|
||
|
LightSeaGreen,
|
||
|
LightSkyBlue,
|
||
|
LightSlateGray,
|
||
|
LightSlateGrey,
|
||
|
LightSteelBlue,
|
||
|
LightYellow,
|
||
|
Lime,
|
||
|
LimeGreen,
|
||
|
Linen,
|
||
|
Magenta,
|
||
|
Maroon,
|
||
|
MediumAquaMarine,
|
||
|
MediumBlue,
|
||
|
MediumOrchid,
|
||
|
MediumPurple,
|
||
|
MediumSeaGreen,
|
||
|
MediumSlateBlue,
|
||
|
MediumSpringGreen,
|
||
|
MediumTurquoise,
|
||
|
MediumVioletRed,
|
||
|
MidnightBlue,
|
||
|
MintCream,
|
||
|
MistyRose,
|
||
|
Moccasin,
|
||
|
NavajoWhite,
|
||
|
Navy,
|
||
|
OldLace,
|
||
|
Olive,
|
||
|
OliveDrab,
|
||
|
Orange,
|
||
|
OrangeRed,
|
||
|
Orchid,
|
||
|
PaleGoldenRod,
|
||
|
PaleGreen,
|
||
|
PaleTurquoise,
|
||
|
PaleVioletRed,
|
||
|
PapayaWhip,
|
||
|
PeachPuff,
|
||
|
Peru,
|
||
|
Pink,
|
||
|
Plum,
|
||
|
PowderBlue,
|
||
|
Purple,
|
||
|
RebeccaPurple,
|
||
|
Red,
|
||
|
RosyBrown,
|
||
|
RoyalBlue,
|
||
|
SaddleBrown,
|
||
|
Salmon,
|
||
|
SandyBrown,
|
||
|
SeaGreen,
|
||
|
SeaShell,
|
||
|
Sienna,
|
||
|
Silver,
|
||
|
SkyBlue,
|
||
|
SlateBlue,
|
||
|
SlateGray,
|
||
|
SlateGrey,
|
||
|
Snow,
|
||
|
SpringGreen,
|
||
|
SteelBlue,
|
||
|
Tan,
|
||
|
Teal,
|
||
|
Thistle,
|
||
|
Tomato,
|
||
|
Turquoise,
|
||
|
Violet,
|
||
|
Wheat,
|
||
|
White,
|
||
|
WhiteSmoke,
|
||
|
Yellow,
|
||
|
YellowGreen,
|
||
|
}
|
||
|
|
||
|
impl ToString for Color {
|
||
|
fn to_string(&self) -> String {
|
||
|
match self {
|
||
|
Color::AliceBlue => "AliceBlue",
|
||
|
Color::AntiqueWhite => "AntiqueWhite",
|
||
|
Color::Aqua => "Aqua",
|
||
|
Color::Aquamarine => "Aquamarine",
|
||
|
Color::Azure => "Azure",
|
||
|
Color::Beige => "Beige",
|
||
|
Color::Bisque => "Bisque",
|
||
|
Color::Black => "Black",
|
||
|
Color::BlanchedAlmond => "BlanchedAlmond",
|
||
|
Color::Blue => "Blue",
|
||
|
Color::BlueViolet => "BlueViolet",
|
||
|
Color::Brown => "Brown",
|
||
|
Color::BurlyWood => "BurlyWood",
|
||
|
Color::CadetBlue => "CadetBlue",
|
||
|
Color::Chartreuse => "Chartreuse",
|
||
|
Color::Chocolate => "Chocolate",
|
||
|
Color::Coral => "Coral",
|
||
|
Color::CornflowerBlue => "CornflowerBlue",
|
||
|
Color::Cornsilk => "Cornsilk",
|
||
|
Color::Crimson => "Crimson",
|
||
|
Color::Cyan => "Cyan",
|
||
|
Color::DarkBlue => "DarkBlue",
|
||
|
Color::DarkCyan => "DarkCyan",
|
||
|
Color::DarkGoldenRod => "DarkGoldenRod",
|
||
|
Color::DarkGray => "DarkGray",
|
||
|
Color::DarkGrey => "DarkGrey",
|
||
|
Color::DarkGreen => "DarkGreen",
|
||
|
Color::DarkKhaki => "DarkKhaki",
|
||
|
Color::DarkMagenta => "DarkMagenta",
|
||
|
Color::DarkOliveGreen => "DarkOliveGreen",
|
||
|
Color::DarkOrange => "DarkOrange",
|
||
|
Color::DarkOrchid => "DarkOrchid",
|
||
|
Color::DarkRed => "DarkRed",
|
||
|
Color::DarkSalmon => "DarkSalmon",
|
||
|
Color::DarkSeaGreen => "DarkSeaGreen",
|
||
|
Color::DarkSlateBlue => "DarkSlateBlue",
|
||
|
Color::DarkSlateGray => "DarkSlateGray",
|
||
|
Color::DarkSlateGrey => "DarkSlateGrey",
|
||
|
Color::DarkTurquoise => "DarkTurquoise",
|
||
|
Color::DarkViolet => "DarkViolet",
|
||
|
Color::DeepPink => "DeepPink",
|
||
|
Color::DeepSkyBlue => "DeepSkyBlue",
|
||
|
Color::DimGray => "DimGray",
|
||
|
Color::DimGrey => "DimGrey",
|
||
|
Color::DodgerBlue => "DodgerBlue",
|
||
|
Color::FireBrick => "FireBrick",
|
||
|
Color::FloralWhite => "FloralWhite",
|
||
|
Color::ForestGreen => "ForestGreen",
|
||
|
Color::Fuchsia => "Fuchsia",
|
||
|
Color::Gainsboro => "Gainsboro",
|
||
|
Color::GhostWhite => "GhostWhite",
|
||
|
Color::Gold => "Gold",
|
||
|
Color::GoldenRod => "GoldenRod",
|
||
|
Color::Gray => "Gray",
|
||
|
Color::Grey => "Grey",
|
||
|
Color::Green => "Green",
|
||
|
Color::GreenYellow => "GreenYellow",
|
||
|
Color::HoneyDew => "HoneyDew",
|
||
|
Color::HotPink => "HotPink",
|
||
|
Color::IndianRed => "IndianRed",
|
||
|
Color::Indigo => "Indigo",
|
||
|
Color::Ivory => "Ivory",
|
||
|
Color::Khaki => "Khaki",
|
||
|
Color::Lavender => "Lavender",
|
||
|
Color::LavenderBlush => "LavenderBlush",
|
||
|
Color::LawnGreen => "LawnGreen",
|
||
|
Color::LemonChiffon => "LemonChiffon",
|
||
|
Color::LightBlue => "LightBlue",
|
||
|
Color::LightCoral => "LightCoral",
|
||
|
Color::LightCyan => "LightCyan",
|
||
|
Color::LightGoldenRodYellow => "LightGoldenRodYellow",
|
||
|
Color::LightGray => "LightGray",
|
||
|
Color::LightGrey => "LightGrey",
|
||
|
Color::LightGreen => "LightGreen",
|
||
|
Color::LightPink => "LightPink",
|
||
|
Color::LightSalmon => "LightSalmon",
|
||
|
Color::LightSeaGreen => "LightSeaGreen",
|
||
|
Color::LightSkyBlue => "LightSkyBlue",
|
||
|
Color::LightSlateGray => "LightSlateGray",
|
||
|
Color::LightSlateGrey => "LightSlateGrey",
|
||
|
Color::LightSteelBlue => "LightSteelBlue",
|
||
|
Color::LightYellow => "LightYellow",
|
||
|
Color::Lime => "Lime",
|
||
|
Color::LimeGreen => "LimeGreen",
|
||
|
Color::Linen => "Linen",
|
||
|
Color::Magenta => "Magenta",
|
||
|
Color::Maroon => "Maroon",
|
||
|
Color::MediumAquaMarine => "MediumAquaMarine",
|
||
|
Color::MediumBlue => "MediumBlue",
|
||
|
Color::MediumOrchid => "MediumOrchid",
|
||
|
Color::MediumPurple => "MediumPurple",
|
||
|
Color::MediumSeaGreen => "MediumSeaGreen",
|
||
|
Color::MediumSlateBlue => "MediumSlateBlue",
|
||
|
Color::MediumSpringGreen => "MediumSpringGreen",
|
||
|
Color::MediumTurquoise => "MediumTurquoise",
|
||
|
Color::MediumVioletRed => "MediumVioletRed",
|
||
|
Color::MidnightBlue => "MidnightBlue",
|
||
|
Color::MintCream => "MintCream",
|
||
|
Color::MistyRose => "MistyRose",
|
||
|
Color::Moccasin => "Moccasin",
|
||
|
Color::NavajoWhite => "NavajoWhite",
|
||
|
Color::Navy => "Navy",
|
||
|
Color::OldLace => "OldLace",
|
||
|
Color::Olive => "Olive",
|
||
|
Color::OliveDrab => "OliveDrab",
|
||
|
Color::Orange => "Orange",
|
||
|
Color::OrangeRed => "OrangeRed",
|
||
|
Color::Orchid => "Orchid",
|
||
|
Color::PaleGoldenRod => "PaleGoldenRod",
|
||
|
Color::PaleGreen => "PaleGreen",
|
||
|
Color::PaleTurquoise => "PaleTurquoise",
|
||
|
Color::PaleVioletRed => "PaleVioletRed",
|
||
|
Color::PapayaWhip => "PapayaWhip",
|
||
|
Color::PeachPuff => "PeachPuff",
|
||
|
Color::Peru => "Peru",
|
||
|
Color::Pink => "Pink",
|
||
|
Color::Plum => "Plum",
|
||
|
Color::PowderBlue => "PowderBlue",
|
||
|
Color::Purple => "Purple",
|
||
|
Color::RebeccaPurple => "RebeccaPurple",
|
||
|
Color::Red => "Red",
|
||
|
Color::RosyBrown => "RosyBrown",
|
||
|
Color::RoyalBlue => "RoyalBlue",
|
||
|
Color::SaddleBrown => "SaddleBrown",
|
||
|
Color::Salmon => "Salmon",
|
||
|
Color::SandyBrown => "SandyBrown",
|
||
|
Color::SeaGreen => "SeaGreen",
|
||
|
Color::SeaShell => "SeaShell",
|
||
|
Color::Sienna => "Sienna",
|
||
|
Color::Silver => "Silver",
|
||
|
Color::SkyBlue => "SkyBlue",
|
||
|
Color::SlateBlue => "SlateBlue",
|
||
|
Color::SlateGray => "SlateGray",
|
||
|
Color::SlateGrey => "SlateGrey",
|
||
|
Color::Snow => "Snow",
|
||
|
Color::SpringGreen => "SpringGreen",
|
||
|
Color::SteelBlue => "SteelBlue",
|
||
|
Color::Tan => "Tan",
|
||
|
Color::Teal => "Teal",
|
||
|
Color::Thistle => "Thistle",
|
||
|
Color::Tomato => "Tomato",
|
||
|
Color::Turquoise => "Turquoise",
|
||
|
Color::Violet => "Violet",
|
||
|
Color::Wheat => "Wheat",
|
||
|
Color::White => "White",
|
||
|
Color::WhiteSmoke => "WhiteSmoke",
|
||
|
Color::Yellow => "Yellow",
|
||
|
Color::YellowGreen => "YellowGreen",
|
||
|
}
|
||
|
.to_string()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl Color {
|
||
|
pub fn to_hex(&self) -> String {
|
||
|
match self {
|
||
|
Color::AliceBlue => "#f0f8ff",
|
||
|
Color::AntiqueWhite => "#faebd7",
|
||
|
Color::Aqua => "#00ffff",
|
||
|
Color::Aquamarine => "#7fffd4",
|
||
|
Color::Azure => "#f0ffff",
|
||
|
Color::Beige => "#f5f5dc",
|
||
|
Color::Bisque => "#ffe4c4",
|
||
|
Color::Black => "#000000",
|
||
|
Color::BlanchedAlmond => "#ffebcd",
|
||
|
Color::Blue => "#0000ff",
|
||
|
Color::BlueViolet => "#8a2be2",
|
||
|
Color::Brown => "#a52a2a",
|
||
|
Color::BurlyWood => "#deb887",
|
||
|
Color::CadetBlue => "#5f9ea0",
|
||
|
Color::Chartreuse => "#7fff00",
|
||
|
Color::Chocolate => "#d2691e",
|
||
|
Color::Coral => "#ff7f50",
|
||
|
Color::CornflowerBlue => "#6495ed",
|
||
|
Color::Cornsilk => "#fff8dc",
|
||
|
Color::Crimson => "#dc143c",
|
||
|
Color::Cyan => "#00ffff",
|
||
|
Color::DarkBlue => "#00008b",
|
||
|
Color::DarkCyan => "#008b8b",
|
||
|
Color::DarkGoldenRod => "#b8860b",
|
||
|
Color::DarkGray => "#a9a9a9",
|
||
|
Color::DarkGrey => "#a9a9a9",
|
||
|
Color::DarkGreen => "#006400",
|
||
|
Color::DarkKhaki => "#bdb76b",
|
||
|
Color::DarkMagenta => "#8b008b",
|
||
|
Color::DarkOliveGreen => "#556b2f",
|
||
|
Color::DarkOrange => "#ff8c00",
|
||
|
Color::DarkOrchid => "#9932cc",
|
||
|
Color::DarkRed => "#8b0000",
|
||
|
Color::DarkSalmon => "#e9967a",
|
||
|
Color::DarkSeaGreen => "#8fbc8f",
|
||
|
Color::DarkSlateBlue => "#483d8b",
|
||
|
Color::DarkSlateGray => "#2f4f4f",
|
||
|
Color::DarkSlateGrey => "#2f4f4f",
|
||
|
Color::DarkTurquoise => "#00ced1",
|
||
|
Color::DarkViolet => "#9400d3",
|
||
|
Color::DeepPink => "#ff1493",
|
||
|
Color::DeepSkyBlue => "#00bfff",
|
||
|
Color::DimGray => "#696969",
|
||
|
Color::DimGrey => "#696969",
|
||
|
Color::DodgerBlue => "#1e90ff",
|
||
|
Color::FireBrick => "#b22222",
|
||
|
Color::FloralWhite => "#fffaf0",
|
||
|
Color::ForestGreen => "#228b22",
|
||
|
Color::Fuchsia => "#ff00ff",
|
||
|
Color::Gainsboro => "#dcdcdc",
|
||
|
Color::GhostWhite => "#f8f8ff",
|
||
|
Color::Gold => "#ffd700",
|
||
|
Color::GoldenRod => "#daa520",
|
||
|
Color::Gray => "#808080",
|
||
|
Color::Grey => "#808080",
|
||
|
Color::Green => "#008000",
|
||
|
Color::GreenYellow => "#adff2f",
|
||
|
Color::HoneyDew => "#f0fff0",
|
||
|
Color::HotPink => "#ff69b4",
|
||
|
Color::IndianRed => "#cd5c5c",
|
||
|
Color::Indigo => "#4b0082",
|
||
|
Color::Ivory => "#fffff0",
|
||
|
Color::Khaki => "#f0e68c",
|
||
|
Color::Lavender => "#e6e6fa",
|
||
|
Color::LavenderBlush => "#fff0f5",
|
||
|
Color::LawnGreen => "#7cfc00",
|
||
|
Color::LemonChiffon => "#fffacd",
|
||
|
Color::LightBlue => "#add8e6",
|
||
|
Color::LightCoral => "#f08080",
|
||
|
Color::LightCyan => "#e0ffff",
|
||
|
Color::LightGoldenRodYellow => "#fafad2",
|
||
|
Color::LightGray => "#d3d3d3",
|
||
|
Color::LightGrey => "#d3d3d3",
|
||
|
Color::LightGreen => "#90ee90",
|
||
|
Color::LightPink => "#ffb6c1",
|
||
|
Color::LightSalmon => "#ffa07a",
|
||
|
Color::LightSeaGreen => "#20b2aa",
|
||
|
Color::LightSkyBlue => "#87cefa",
|
||
|
Color::LightSlateGray => "#778899",
|
||
|
Color::LightSlateGrey => "#778899",
|
||
|
Color::LightSteelBlue => "#b0c4de",
|
||
|
Color::LightYellow => "#ffffe0",
|
||
|
Color::Lime => "#00ff00",
|
||
|
Color::LimeGreen => "#32cd32",
|
||
|
Color::Linen => "#faf0e6",
|
||
|
Color::Magenta => "#ff00ff",
|
||
|
Color::Maroon => "#800000",
|
||
|
Color::MediumAquaMarine => "#66cdaa",
|
||
|
Color::MediumBlue => "#0000cd",
|
||
|
Color::MediumOrchid => "#ba55d3",
|
||
|
Color::MediumPurple => "#9370db",
|
||
|
Color::MediumSeaGreen => "#3cb371",
|
||
|
Color::MediumSlateBlue => "#7b68ee",
|
||
|
Color::MediumSpringGreen => "#00fa9a",
|
||
|
Color::MediumTurquoise => "#48d1cc",
|
||
|
Color::MediumVioletRed => "#c71585",
|
||
|
Color::MidnightBlue => "#191970",
|
||
|
Color::MintCream => "#f5fffa",
|
||
|
Color::MistyRose => "#ffe4e1",
|
||
|
Color::Moccasin => "#ffe4b5",
|
||
|
Color::NavajoWhite => "#ffdead",
|
||
|
Color::Navy => "#000080",
|
||
|
Color::OldLace => "#fdf5e6",
|
||
|
Color::Olive => "#808000",
|
||
|
Color::OliveDrab => "#6b8e23",
|
||
|
Color::Orange => "#ffa500",
|
||
|
Color::OrangeRed => "#ff4500",
|
||
|
Color::Orchid => "#da70d6",
|
||
|
Color::PaleGoldenRod => "#eee8aa",
|
||
|
Color::PaleGreen => "#98fb98",
|
||
|
Color::PaleTurquoise => "#afeeee",
|
||
|
Color::PaleVioletRed => "#db7093",
|
||
|
Color::PapayaWhip => "#ffefd5",
|
||
|
Color::PeachPuff => "#ffdab9",
|
||
|
Color::Peru => "#cd853f",
|
||
|
Color::Pink => "#ffc0cb",
|
||
|
Color::Plum => "#dda0dd",
|
||
|
Color::PowderBlue => "#b0e0e6",
|
||
|
Color::Purple => "#800080",
|
||
|
Color::RebeccaPurple => "#663399",
|
||
|
Color::Red => "#ff0000",
|
||
|
Color::RosyBrown => "#bc8f8f",
|
||
|
Color::RoyalBlue => "#4169e1",
|
||
|
Color::SaddleBrown => "#8b4513",
|
||
|
Color::Salmon => "#fa8072",
|
||
|
Color::SandyBrown => "#f4a460",
|
||
|
Color::SeaGreen => "#2e8b57",
|
||
|
Color::SeaShell => "#fff5ee",
|
||
|
Color::Sienna => "#a0522d",
|
||
|
Color::Silver => "#c0c0c0",
|
||
|
Color::SkyBlue => "#87ceeb",
|
||
|
Color::SlateBlue => "#6a5acd",
|
||
|
Color::SlateGray => "#708090",
|
||
|
Color::SlateGrey => "#708090",
|
||
|
Color::Snow => "#fffafa",
|
||
|
Color::SpringGreen => "#00ff7f",
|
||
|
Color::SteelBlue => "#4682b4",
|
||
|
Color::Tan => "#d2b48c",
|
||
|
Color::Teal => "#008080",
|
||
|
Color::Thistle => "#d8bfd8",
|
||
|
Color::Tomato => "#ff6347",
|
||
|
Color::Turquoise => "#40e0d0",
|
||
|
Color::Violet => "#ee82ee",
|
||
|
Color::Wheat => "#f5deb3",
|
||
|
Color::White => "#ffffff",
|
||
|
Color::WhiteSmoke => "#f5f5f5",
|
||
|
Color::Yellow => "#ffff00",
|
||
|
Color::YellowGreen => "#9acd32",
|
||
|
}
|
||
|
.to_string()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl FromStr for Color {
|
||
|
type Err = String;
|
||
|
|
||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||
|
let m = if s.starts_with('#') {
|
||
|
s.to_lowercase()
|
||
|
} else {
|
||
|
s.to_string()
|
||
|
};
|
||
|
let c = match m.as_str() {
|
||
|
"AliceBlue" | "#f0f8ff" => Color::AliceBlue,
|
||
|
"AntiqueWhite" | "#faebd7" => Color::AntiqueWhite,
|
||
|
"Aqua" | "#00ffff" => Color::Aqua,
|
||
|
"Aquamarine" | "#7fffd4" => Color::Aquamarine,
|
||
|
"Azure" | "#f0ffff" => Color::Azure,
|
||
|
"Beige" | "#f5f5dc" => Color::Beige,
|
||
|
"Bisque" | "#ffe4c4" => Color::Bisque,
|
||
|
"Black" | "#000000" => Color::Black,
|
||
|
"BlanchedAlmond" | "#ffebcd" => Color::BlanchedAlmond,
|
||
|
"Blue" | "#0000ff" => Color::Blue,
|
||
|
"BlueViolet" | "#8a2be2" => Color::BlueViolet,
|
||
|
"Brown" | "#a52a2a" => Color::Brown,
|
||
|
"BurlyWood" | "#deb887" => Color::BurlyWood,
|
||
|
"CadetBlue" | "#5f9ea0" => Color::CadetBlue,
|
||
|
"Chartreuse" | "#7fff00" => Color::Chartreuse,
|
||
|
"Chocolate" | "#d2691e" => Color::Chocolate,
|
||
|
"Coral" | "#ff7f50" => Color::Coral,
|
||
|
"CornflowerBlue" | "#6495ed" => Color::CornflowerBlue,
|
||
|
"Cornsilk" | "#fff8dc" => Color::Cornsilk,
|
||
|
"Crimson" | "#dc143c" => Color::Crimson,
|
||
|
"Cyan" | "#00ffff" => Color::Cyan,
|
||
|
"DarkBlue" | "#00008b" => Color::DarkBlue,
|
||
|
"DarkCyan" | "#008b8b" => Color::DarkCyan,
|
||
|
"DarkGoldenRod" | "#b8860b" => Color::DarkGoldenRod,
|
||
|
"DarkGray" | "#a9a9a9" => Color::DarkGray,
|
||
|
"DarkGrey" | "#a9a9a9" => Color::DarkGrey,
|
||
|
"DarkGreen" | "#006400" => Color::DarkGreen,
|
||
|
"DarkKhaki" | "#bdb76b" => Color::DarkKhaki,
|
||
|
"DarkMagenta" | "#8b008b" => Color::DarkMagenta,
|
||
|
"DarkOliveGreen" | "#556b2f" => Color::DarkOliveGreen,
|
||
|
"DarkOrange" | "#ff8c00" => Color::DarkOrange,
|
||
|
"DarkOrchid" | "#9932cc" => Color::DarkOrchid,
|
||
|
"DarkRed" | "#8b0000" => Color::DarkRed,
|
||
|
"DarkSalmon" | "#e9967a" => Color::DarkSalmon,
|
||
|
"DarkSeaGreen" | "#8fbc8f" => Color::DarkSeaGreen,
|
||
|
"DarkSlateBlue" | "#483d8b" => Color::DarkSlateBlue,
|
||
|
"DarkSlateGray" | "#2f4f4f" => Color::DarkSlateGray,
|
||
|
"DarkSlateGrey" | "#2f4f4f" => Color::DarkSlateGrey,
|
||
|
"DarkTurquoise" | "#00ced1" => Color::DarkTurquoise,
|
||
|
"DarkViolet" | "#9400d3" => Color::DarkViolet,
|
||
|
"DeepPink" | "#ff1493" => Color::DeepPink,
|
||
|
"DeepSkyBlue" | "#00bfff" => Color::DeepSkyBlue,
|
||
|
"DimGray" | "#696969" => Color::DimGray,
|
||
|
"DimGrey" | "#696969" => Color::DimGrey,
|
||
|
"DodgerBlue" | "#1e90ff" => Color::DodgerBlue,
|
||
|
"FireBrick" | "#b22222" => Color::FireBrick,
|
||
|
"FloralWhite" | "#fffaf0" => Color::FloralWhite,
|
||
|
"ForestGreen" | "#228b22" => Color::ForestGreen,
|
||
|
"Fuchsia" | "#ff00ff" => Color::Fuchsia,
|
||
|
"Gainsboro" | "#dcdcdc" => Color::Gainsboro,
|
||
|
"GhostWhite" | "#f8f8ff" => Color::GhostWhite,
|
||
|
"Gold" | "#ffd700" => Color::Gold,
|
||
|
"GoldenRod" | "#daa520" => Color::GoldenRod,
|
||
|
"Gray" | "#808080" => Color::Gray,
|
||
|
"Grey" | "#808080" => Color::Grey,
|
||
|
"Green" | "#008000" => Color::Green,
|
||
|
"GreenYellow" | "#adff2f" => Color::GreenYellow,
|
||
|
"HoneyDew" | "#f0fff0" => Color::HoneyDew,
|
||
|
"HotPink" | "#ff69b4" => Color::HotPink,
|
||
|
"IndianRed" | "#cd5c5c" => Color::IndianRed,
|
||
|
"Indigo" | "#4b0082" => Color::Indigo,
|
||
|
"Ivory" | "#fffff0" => Color::Ivory,
|
||
|
"Khaki" | "#f0e68c" => Color::Khaki,
|
||
|
"Lavender" | "#e6e6fa" => Color::Lavender,
|
||
|
"LavenderBlush" | "#fff0f5" => Color::LavenderBlush,
|
||
|
"LawnGreen" | "#7cfc00" => Color::LawnGreen,
|
||
|
"LemonChiffon" | "#fffacd" => Color::LemonChiffon,
|
||
|
"LightBlue" | "#add8e6" => Color::LightBlue,
|
||
|
"LightCoral" | "#f08080" => Color::LightCoral,
|
||
|
"LightCyan" | "#e0ffff" => Color::LightCyan,
|
||
|
"LightGoldenRodYellow" | "#fafad2" => Color::LightGoldenRodYellow,
|
||
|
"LightGray" | "#d3d3d3" => Color::LightGray,
|
||
|
"LightGrey" | "#d3d3d3" => Color::LightGrey,
|
||
|
"LightGreen" | "#90ee90" => Color::LightGreen,
|
||
|
"LightPink" | "#ffb6c1" => Color::LightPink,
|
||
|
"LightSalmon" | "#ffa07a" => Color::LightSalmon,
|
||
|
"LightSeaGreen" | "#20b2aa" => Color::LightSeaGreen,
|
||
|
"LightSkyBlue" | "#87cefa" => Color::LightSkyBlue,
|
||
|
"LightSlateGray" | "#778899" => Color::LightSlateGray,
|
||
|
"LightSlateGrey" | "#778899" => Color::LightSlateGrey,
|
||
|
"LightSteelBlue" | "#b0c4de" => Color::LightSteelBlue,
|
||
|
"LightYellow" | "#ffffe0" => Color::LightYellow,
|
||
|
"Lime" | "#00ff00" => Color::Lime,
|
||
|
"LimeGreen" | "#32cd32" => Color::LimeGreen,
|
||
|
"Linen" | "#faf0e6" => Color::Linen,
|
||
|
"Magenta" | "#ff00ff" => Color::Magenta,
|
||
|
"Maroon" | "#800000" => Color::Maroon,
|
||
|
"MediumAquaMarine" | "#66cdaa" => Color::MediumAquaMarine,
|
||
|
"MediumBlue" | "#0000cd" => Color::MediumBlue,
|
||
|
"MediumOrchid" | "#ba55d3" => Color::MediumOrchid,
|
||
|
"MediumPurple" | "#9370db" => Color::MediumPurple,
|
||
|
"MediumSeaGreen" | "#3cb371" => Color::MediumSeaGreen,
|
||
|
"MediumSlateBlue" | "#7b68ee" => Color::MediumSlateBlue,
|
||
|
"MediumSpringGreen" | "#00fa9a" => Color::MediumSpringGreen,
|
||
|
"MediumTurquoise" | "#48d1cc" => Color::MediumTurquoise,
|
||
|
"MediumVioletRed" | "#c71585" => Color::MediumVioletRed,
|
||
|
"MidnightBlue" | "#191970" => Color::MidnightBlue,
|
||
|
"MintCream" | "#f5fffa" => Color::MintCream,
|
||
|
"MistyRose" | "#ffe4e1" => Color::MistyRose,
|
||
|
"Moccasin" | "#ffe4b5" => Color::Moccasin,
|
||
|
"NavajoWhite" | "#ffdead" => Color::NavajoWhite,
|
||
|
"Navy" | "#000080" => Color::Navy,
|
||
|
"OldLace" | "#fdf5e6" => Color::OldLace,
|
||
|
"Olive" | "#808000" => Color::Olive,
|
||
|
"OliveDrab" | "#6b8e23" => Color::OliveDrab,
|
||
|
"Orange" | "#ffa500" => Color::Orange,
|
||
|
"OrangeRed" | "#ff4500" => Color::OrangeRed,
|
||
|
"Orchid" | "#da70d6" => Color::Orchid,
|
||
|
"PaleGoldenRod" | "#eee8aa" => Color::PaleGoldenRod,
|
||
|
"PaleGreen" | "#98fb98" => Color::PaleGreen,
|
||
|
"PaleTurquoise" | "#afeeee" => Color::PaleTurquoise,
|
||
|
"PaleVioletRed" | "#db7093" => Color::PaleVioletRed,
|
||
|
"PapayaWhip" | "#ffefd5" => Color::PapayaWhip,
|
||
|
"PeachPuff" | "#ffdab9" => Color::PeachPuff,
|
||
|
"Peru" | "#cd853f" => Color::Peru,
|
||
|
"Pink" | "#ffc0cb" => Color::Pink,
|
||
|
"Plum" | "#dda0dd" => Color::Plum,
|
||
|
"PowderBlue" | "#b0e0e6" => Color::PowderBlue,
|
||
|
"Purple" | "#800080" => Color::Purple,
|
||
|
"RebeccaPurple" | "#663399" => Color::RebeccaPurple,
|
||
|
"Red" | "#ff0000" => Color::Red,
|
||
|
"RosyBrown" | "#bc8f8f" => Color::RosyBrown,
|
||
|
"RoyalBlue" | "#4169e1" => Color::RoyalBlue,
|
||
|
"SaddleBrown" | "#8b4513" => Color::SaddleBrown,
|
||
|
"Salmon" | "#fa8072" => Color::Salmon,
|
||
|
"SandyBrown" | "#f4a460" => Color::SandyBrown,
|
||
|
"SeaGreen" | "#2e8b57" => Color::SeaGreen,
|
||
|
"SeaShell" | "#fff5ee" => Color::SeaShell,
|
||
|
"Sienna" | "#a0522d" => Color::Sienna,
|
||
|
"Silver" | "#c0c0c0" => Color::Silver,
|
||
|
"SkyBlue" | "#87ceeb" => Color::SkyBlue,
|
||
|
"SlateBlue" | "#6a5acd" => Color::SlateBlue,
|
||
|
"SlateGray" | "#708090" => Color::SlateGray,
|
||
|
"SlateGrey" | "#708090" => Color::SlateGrey,
|
||
|
"Snow" | "#fffafa" => Color::Snow,
|
||
|
"SpringGreen" | "#00ff7f" => Color::SpringGreen,
|
||
|
"SteelBlue" | "#4682b4" => Color::SteelBlue,
|
||
|
"Tan" | "#d2b48c" => Color::Tan,
|
||
|
"Teal" | "#008080" => Color::Teal,
|
||
|
"Thistle" | "#d8bfd8" => Color::Thistle,
|
||
|
"Tomato" | "#ff6347" => Color::Tomato,
|
||
|
"Turquoise" | "#40e0d0" => Color::Turquoise,
|
||
|
"Violet" | "#ee82ee" => Color::Violet,
|
||
|
"Wheat" | "#f5deb3" => Color::Wheat,
|
||
|
"White" | "#ffffff" => Color::White,
|
||
|
"WhiteSmoke" | "#f5f5f5" => Color::WhiteSmoke,
|
||
|
"Yellow" | "#ffff00" => Color::Yellow,
|
||
|
"YellowGreen" | "#9acd32" => Color::YellowGreen,
|
||
|
_ => return Err(format!("invalid predefined color {:?}", s)),
|
||
|
};
|
||
|
Ok(c)
|
||
|
}
|
||
|
}
|