use crate::{Srgb, ToAlpha};
use core::fmt;

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Named {
	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,
	Darkgreen,
	Darkgrey,
	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,
	Green,
	Greenyellow,
	Grey,
	Honeydew,
	Hotpink,
	Indianred,
	Indigo,
	Ivory,
	Khaki,
	Lavender,
	Lavenderblush,
	Lawngreen,
	Lemonchiffon,
	Lightblue,
	Lightcoral,
	Lightcyan,
	Lightgoldenrodyellow,
	Lightgray,
	Lightgreen,
	Lightgrey,
	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 Named {
	pub fn iter() -> impl Iterator<Item = Named> {
		[
			Named::Aliceblue,
			Named::Antiquewhite,
			Named::Aqua,
			Named::Aquamarine,
			Named::Azure,
			Named::Beige,
			Named::Bisque,
			Named::Black,
			Named::Blanchedalmond,
			Named::Blue,
			Named::Blueviolet,
			Named::Brown,
			Named::Burlywood,
			Named::Cadetblue,
			Named::Chartreuse,
			Named::Chocolate,
			Named::Coral,
			Named::Cornflowerblue,
			Named::Cornsilk,
			Named::Crimson,
			Named::Cyan,
			Named::Darkblue,
			Named::Darkcyan,
			Named::Darkgoldenrod,
			Named::Darkgray,
			Named::Darkgreen,
			Named::Darkgrey,
			Named::Darkkhaki,
			Named::Darkmagenta,
			Named::Darkolivegreen,
			Named::Darkorange,
			Named::Darkorchid,
			Named::Darkred,
			Named::Darksalmon,
			Named::Darkseagreen,
			Named::Darkslateblue,
			Named::Darkslategray,
			Named::Darkslategrey,
			Named::Darkturquoise,
			Named::Darkviolet,
			Named::Deeppink,
			Named::Deepskyblue,
			Named::Dimgray,
			Named::Dimgrey,
			Named::Dodgerblue,
			Named::Firebrick,
			Named::Floralwhite,
			Named::Forestgreen,
			Named::Fuchsia,
			Named::Gainsboro,
			Named::Ghostwhite,
			Named::Gold,
			Named::Goldenrod,
			Named::Gray,
			Named::Green,
			Named::Greenyellow,
			Named::Grey,
			Named::Honeydew,
			Named::Hotpink,
			Named::Indianred,
			Named::Indigo,
			Named::Ivory,
			Named::Khaki,
			Named::Lavender,
			Named::Lavenderblush,
			Named::Lawngreen,
			Named::Lemonchiffon,
			Named::Lightblue,
			Named::Lightcoral,
			Named::Lightcyan,
			Named::Lightgoldenrodyellow,
			Named::Lightgray,
			Named::Lightgreen,
			Named::Lightgrey,
			Named::Lightpink,
			Named::Lightsalmon,
			Named::Lightseagreen,
			Named::Lightskyblue,
			Named::Lightslategray,
			Named::Lightslategrey,
			Named::Lightsteelblue,
			Named::Lightyellow,
			Named::Lime,
			Named::Limegreen,
			Named::Linen,
			Named::Magenta,
			Named::Maroon,
			Named::Mediumaquamarine,
			Named::Mediumblue,
			Named::Mediumorchid,
			Named::Mediumpurple,
			Named::Mediumseagreen,
			Named::Mediumslateblue,
			Named::Mediumspringgreen,
			Named::Mediumturquoise,
			Named::Mediumvioletred,
			Named::Midnightblue,
			Named::Mintcream,
			Named::Mistyrose,
			Named::Moccasin,
			Named::Navajowhite,
			Named::Navy,
			Named::Oldlace,
			Named::Olive,
			Named::Olivedrab,
			Named::Orange,
			Named::Orangered,
			Named::Orchid,
			Named::Palegoldenrod,
			Named::Palegreen,
			Named::Paleturquoise,
			Named::Palevioletred,
			Named::Papayawhip,
			Named::Peachpuff,
			Named::Peru,
			Named::Pink,
			Named::Plum,
			Named::Powderblue,
			Named::Purple,
			Named::Rebeccapurple,
			Named::Red,
			Named::Rosybrown,
			Named::Royalblue,
			Named::Saddlebrown,
			Named::Salmon,
			Named::Sandybrown,
			Named::Seagreen,
			Named::Seashell,
			Named::Sienna,
			Named::Silver,
			Named::Skyblue,
			Named::Slateblue,
			Named::Slategray,
			Named::Slategrey,
			Named::Snow,
			Named::Springgreen,
			Named::Steelblue,
			Named::Tan,
			Named::Teal,
			Named::Thistle,
			Named::Tomato,
			Named::Turquoise,
			Named::Violet,
			Named::Wheat,
			Named::White,
			Named::Whitesmoke,
			Named::Yellow,
			Named::Yellowgreen,
		]
		.into_iter()
	}
}

impl ToAlpha for Named {
	fn to_alpha(&self) -> f32 {
		100.0
	}
}

impl fmt::Display for Named {
	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
		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::Darkgreen => write!(f, "darkgreen"),
			Self::Darkgrey => write!(f, "darkgrey"),
			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::Green => write!(f, "green"),
			Self::Greenyellow => write!(f, "greenyellow"),
			Self::Grey => write!(f, "grey"),
			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::Lightgreen => write!(f, "lightgreen"),
			Self::Lightgrey => write!(f, "lightgrey"),
			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 From<Named> for Srgb {
	fn from(value: Named) -> Srgb {
		let (red, green, blue) = match value {
			Named::Aliceblue => (240, 248, 255),
			Named::Antiquewhite => (250, 235, 215),
			Named::Aqua => (0, 255, 255),
			Named::Aquamarine => (127, 255, 212),
			Named::Azure => (240, 255, 255),
			Named::Beige => (245, 245, 220),
			Named::Bisque => (255, 228, 196),
			Named::Black => (0, 0, 0),
			Named::Blanchedalmond => (255, 235, 205),
			Named::Blue => (0, 0, 255),
			Named::Blueviolet => (138, 43, 226),
			Named::Brown => (165, 42, 42),
			Named::Burlywood => (222, 184, 135),
			Named::Cadetblue => (95, 158, 160),
			Named::Chartreuse => (127, 255, 0),
			Named::Chocolate => (210, 105, 30),
			Named::Coral => (255, 127, 80),
			Named::Cornflowerblue => (100, 149, 237),
			Named::Cornsilk => (255, 248, 220),
			Named::Crimson => (220, 20, 60),
			Named::Cyan => (0, 255, 255),
			Named::Darkblue => (0, 0, 139),
			Named::Darkcyan => (0, 139, 139),
			Named::Darkgoldenrod => (184, 134, 11),
			Named::Darkgray => (169, 169, 169),
			Named::Darkgreen => (0, 100, 0),
			Named::Darkgrey => (169, 169, 169),
			Named::Darkkhaki => (189, 183, 107),
			Named::Darkmagenta => (139, 0, 139),
			Named::Darkolivegreen => (85, 107, 47),
			Named::Darkorange => (255, 140, 0),
			Named::Darkorchid => (153, 50, 204),
			Named::Darkred => (139, 0, 0),
			Named::Darksalmon => (233, 150, 122),
			Named::Darkseagreen => (143, 188, 143),
			Named::Darkslateblue => (72, 61, 139),
			Named::Darkslategray => (47, 79, 79),
			Named::Darkslategrey => (47, 79, 79),
			Named::Darkturquoise => (0, 206, 209),
			Named::Darkviolet => (148, 0, 211),
			Named::Deeppink => (255, 20, 147),
			Named::Deepskyblue => (0, 191, 255),
			Named::Dimgray => (105, 105, 105),
			Named::Dimgrey => (105, 105, 105),
			Named::Dodgerblue => (30, 144, 255),
			Named::Firebrick => (178, 34, 34),
			Named::Floralwhite => (255, 250, 240),
			Named::Forestgreen => (34, 139, 34),
			Named::Fuchsia => (255, 0, 255),
			Named::Gainsboro => (220, 220, 220),
			Named::Ghostwhite => (248, 248, 255),
			Named::Gold => (255, 215, 0),
			Named::Goldenrod => (218, 165, 32),
			Named::Gray => (128, 128, 128),
			Named::Green => (0, 128, 0),
			Named::Greenyellow => (173, 255, 47),
			Named::Grey => (128, 128, 128),
			Named::Honeydew => (240, 255, 240),
			Named::Hotpink => (255, 105, 180),
			Named::Indianred => (205, 92, 92),
			Named::Indigo => (75, 0, 130),
			Named::Ivory => (255, 255, 240),
			Named::Khaki => (240, 230, 140),
			Named::Lavender => (230, 230, 250),
			Named::Lavenderblush => (255, 240, 245),
			Named::Lawngreen => (124, 252, 0),
			Named::Lemonchiffon => (255, 250, 205),
			Named::Lightblue => (173, 216, 230),
			Named::Lightcoral => (240, 128, 128),
			Named::Lightcyan => (224, 255, 255),
			Named::Lightgoldenrodyellow => (250, 250, 210),
			Named::Lightgray => (211, 211, 211),
			Named::Lightgreen => (144, 238, 144),
			Named::Lightgrey => (211, 211, 211),
			Named::Lightpink => (255, 182, 193),
			Named::Lightsalmon => (255, 160, 122),
			Named::Lightseagreen => (32, 178, 170),
			Named::Lightskyblue => (135, 206, 250),
			Named::Lightslategray => (119, 136, 153),
			Named::Lightslategrey => (119, 136, 153),
			Named::Lightsteelblue => (176, 196, 222),
			Named::Lightyellow => (255, 255, 224),
			Named::Lime => (0, 255, 0),
			Named::Limegreen => (50, 205, 50),
			Named::Linen => (250, 240, 230),
			Named::Magenta => (255, 0, 255),
			Named::Maroon => (128, 0, 0),
			Named::Mediumaquamarine => (102, 205, 170),
			Named::Mediumblue => (0, 0, 205),
			Named::Mediumorchid => (186, 85, 211),
			Named::Mediumpurple => (147, 112, 219),
			Named::Mediumseagreen => (60, 179, 113),
			Named::Mediumslateblue => (123, 104, 238),
			Named::Mediumspringgreen => (0, 250, 154),
			Named::Mediumturquoise => (72, 209, 204),
			Named::Mediumvioletred => (199, 21, 133),
			Named::Midnightblue => (25, 25, 112),
			Named::Mintcream => (245, 255, 250),
			Named::Mistyrose => (255, 228, 225),
			Named::Moccasin => (255, 228, 181),
			Named::Navajowhite => (255, 222, 173),
			Named::Navy => (0, 0, 128),
			Named::Oldlace => (253, 245, 230),
			Named::Olive => (128, 128, 0),
			Named::Olivedrab => (107, 142, 35),
			Named::Orange => (255, 165, 0),
			Named::Orangered => (255, 69, 0),
			Named::Orchid => (218, 112, 214),
			Named::Palegoldenrod => (238, 232, 170),
			Named::Palegreen => (152, 251, 152),
			Named::Paleturquoise => (175, 238, 238),
			Named::Palevioletred => (219, 112, 147),
			Named::Papayawhip => (255, 239, 213),
			Named::Peachpuff => (255, 218, 185),
			Named::Peru => (205, 133, 63),
			Named::Pink => (255, 192, 203),
			Named::Plum => (221, 160, 221),
			Named::Powderblue => (176, 224, 230),
			Named::Purple => (128, 0, 128),
			Named::Rebeccapurple => (102, 51, 153),
			Named::Red => (255, 0, 0),
			Named::Rosybrown => (188, 143, 143),
			Named::Royalblue => (65, 105, 225),
			Named::Saddlebrown => (139, 69, 19),
			Named::Salmon => (250, 128, 114),
			Named::Sandybrown => (244, 164, 96),
			Named::Seagreen => (46, 139, 87),
			Named::Seashell => (255, 245, 238),
			Named::Sienna => (160, 82, 45),
			Named::Silver => (192, 192, 192),
			Named::Skyblue => (135, 206, 235),
			Named::Slateblue => (106, 90, 205),
			Named::Slategray => (112, 128, 144),
			Named::Slategrey => (112, 128, 144),
			Named::Snow => (255, 250, 250),
			Named::Springgreen => (0, 255, 127),
			Named::Steelblue => (70, 130, 180),
			Named::Tan => (210, 180, 140),
			Named::Teal => (0, 128, 128),
			Named::Thistle => (216, 191, 216),
			Named::Tomato => (255, 99, 71),
			Named::Turquoise => (64, 224, 208),
			Named::Violet => (238, 130, 238),
			Named::Wheat => (245, 222, 179),
			Named::White => (255, 255, 255),
			Named::Whitesmoke => (245, 245, 245),
			Named::Yellow => (255, 255, 0),
			Named::Yellowgreen => (154, 205, 50),
		};
		Srgb::new(red, green, blue, 100.0)
	}
}

#[derive(Debug)]
pub enum ToNamedError {
	NotOpaque,
	NoMatchingName,
}

impl TryFrom<Srgb> for Named {
	type Error = ToNamedError;

	fn try_from(value: Srgb) -> Result<Named, Self::Error> {
		let Srgb { red, green, blue, alpha } = value;
		if alpha != 100.0 {
			Err(ToNamedError::NotOpaque)?;
		}
		match (red, green, blue) {
			(240, 248, 255) => Ok(Named::Aliceblue),
			(250, 235, 215) => Ok(Named::Antiquewhite),
			(0, 255, 255) => Ok(Named::Aqua),
			(127, 255, 212) => Ok(Named::Aquamarine),
			(240, 255, 255) => Ok(Named::Azure),
			(245, 245, 220) => Ok(Named::Beige),
			(255, 228, 196) => Ok(Named::Bisque),
			(0, 0, 0) => Ok(Named::Black),
			(255, 235, 205) => Ok(Named::Blanchedalmond),
			(0, 0, 255) => Ok(Named::Blue),
			(138, 43, 226) => Ok(Named::Blueviolet),
			(165, 42, 42) => Ok(Named::Brown),
			(222, 184, 135) => Ok(Named::Burlywood),
			(95, 158, 160) => Ok(Named::Cadetblue),
			(127, 255, 0) => Ok(Named::Chartreuse),
			(210, 105, 30) => Ok(Named::Chocolate),
			(255, 127, 80) => Ok(Named::Coral),
			(100, 149, 237) => Ok(Named::Cornflowerblue),
			(255, 248, 220) => Ok(Named::Cornsilk),
			(220, 20, 60) => Ok(Named::Crimson),
			(0, 0, 139) => Ok(Named::Darkblue),
			(0, 139, 139) => Ok(Named::Darkcyan),
			(184, 134, 11) => Ok(Named::Darkgoldenrod),
			(169, 169, 169) => Ok(Named::Darkgray),
			(0, 100, 0) => Ok(Named::Darkgreen),
			(189, 183, 107) => Ok(Named::Darkkhaki),
			(139, 0, 139) => Ok(Named::Darkmagenta),
			(85, 107, 47) => Ok(Named::Darkolivegreen),
			(255, 140, 0) => Ok(Named::Darkorange),
			(153, 50, 204) => Ok(Named::Darkorchid),
			(139, 0, 0) => Ok(Named::Darkred),
			(233, 150, 122) => Ok(Named::Darksalmon),
			(143, 188, 143) => Ok(Named::Darkseagreen),
			(72, 61, 139) => Ok(Named::Darkslateblue),
			(47, 79, 79) => Ok(Named::Darkslategray),
			(0, 206, 209) => Ok(Named::Darkturquoise),
			(148, 0, 211) => Ok(Named::Darkviolet),
			(255, 20, 147) => Ok(Named::Deeppink),
			(0, 191, 255) => Ok(Named::Deepskyblue),
			(105, 105, 105) => Ok(Named::Dimgray),
			(30, 144, 255) => Ok(Named::Dodgerblue),
			(178, 34, 34) => Ok(Named::Firebrick),
			(255, 250, 240) => Ok(Named::Floralwhite),
			(34, 139, 34) => Ok(Named::Forestgreen),
			(255, 0, 255) => Ok(Named::Fuchsia),
			(220, 220, 220) => Ok(Named::Gainsboro),
			(248, 248, 255) => Ok(Named::Ghostwhite),
			(255, 215, 0) => Ok(Named::Gold),
			(218, 165, 32) => Ok(Named::Goldenrod),
			(128, 128, 128) => Ok(Named::Gray),
			(0, 128, 0) => Ok(Named::Green),
			(173, 255, 47) => Ok(Named::Greenyellow),
			(240, 255, 240) => Ok(Named::Honeydew),
			(255, 105, 180) => Ok(Named::Hotpink),
			(205, 92, 92) => Ok(Named::Indianred),
			(75, 0, 130) => Ok(Named::Indigo),
			(255, 255, 240) => Ok(Named::Ivory),
			(240, 230, 140) => Ok(Named::Khaki),
			(230, 230, 250) => Ok(Named::Lavender),
			(255, 240, 245) => Ok(Named::Lavenderblush),
			(124, 252, 0) => Ok(Named::Lawngreen),
			(255, 250, 205) => Ok(Named::Lemonchiffon),
			(173, 216, 230) => Ok(Named::Lightblue),
			(240, 128, 128) => Ok(Named::Lightcoral),
			(224, 255, 255) => Ok(Named::Lightcyan),
			(250, 250, 210) => Ok(Named::Lightgoldenrodyellow),
			(211, 211, 211) => Ok(Named::Lightgray),
			(144, 238, 144) => Ok(Named::Lightgreen),
			(255, 182, 193) => Ok(Named::Lightpink),
			(255, 160, 122) => Ok(Named::Lightsalmon),
			(32, 178, 170) => Ok(Named::Lightseagreen),
			(135, 206, 250) => Ok(Named::Lightskyblue),
			(119, 136, 153) => Ok(Named::Lightslategray),
			(176, 196, 222) => Ok(Named::Lightsteelblue),
			(255, 255, 224) => Ok(Named::Lightyellow),
			(0, 255, 0) => Ok(Named::Lime),
			(50, 205, 50) => Ok(Named::Limegreen),
			(250, 240, 230) => Ok(Named::Linen),
			(128, 0, 0) => Ok(Named::Maroon),
			(102, 205, 170) => Ok(Named::Mediumaquamarine),
			(0, 0, 205) => Ok(Named::Mediumblue),
			(186, 85, 211) => Ok(Named::Mediumorchid),
			(147, 112, 219) => Ok(Named::Mediumpurple),
			(60, 179, 113) => Ok(Named::Mediumseagreen),
			(123, 104, 238) => Ok(Named::Mediumslateblue),
			(0, 250, 154) => Ok(Named::Mediumspringgreen),
			(72, 209, 204) => Ok(Named::Mediumturquoise),
			(199, 21, 133) => Ok(Named::Mediumvioletred),
			(25, 25, 112) => Ok(Named::Midnightblue),
			(245, 255, 250) => Ok(Named::Mintcream),
			(255, 228, 225) => Ok(Named::Mistyrose),
			(255, 228, 181) => Ok(Named::Moccasin),
			(255, 222, 173) => Ok(Named::Navajowhite),
			(0, 0, 128) => Ok(Named::Navy),
			(253, 245, 230) => Ok(Named::Oldlace),
			(128, 128, 0) => Ok(Named::Olive),
			(107, 142, 35) => Ok(Named::Olivedrab),
			(255, 165, 0) => Ok(Named::Orange),
			(255, 69, 0) => Ok(Named::Orangered),
			(218, 112, 214) => Ok(Named::Orchid),
			(238, 232, 170) => Ok(Named::Palegoldenrod),
			(152, 251, 152) => Ok(Named::Palegreen),
			(175, 238, 238) => Ok(Named::Paleturquoise),
			(219, 112, 147) => Ok(Named::Palevioletred),
			(255, 239, 213) => Ok(Named::Papayawhip),
			(255, 218, 185) => Ok(Named::Peachpuff),
			(205, 133, 63) => Ok(Named::Peru),
			(255, 192, 203) => Ok(Named::Pink),
			(221, 160, 221) => Ok(Named::Plum),
			(176, 224, 230) => Ok(Named::Powderblue),
			(128, 0, 128) => Ok(Named::Purple),
			(102, 51, 153) => Ok(Named::Rebeccapurple),
			(255, 0, 0) => Ok(Named::Red),
			(188, 143, 143) => Ok(Named::Rosybrown),
			(65, 105, 225) => Ok(Named::Royalblue),
			(139, 69, 19) => Ok(Named::Saddlebrown),
			(250, 128, 114) => Ok(Named::Salmon),
			(244, 164, 96) => Ok(Named::Sandybrown),
			(46, 139, 87) => Ok(Named::Seagreen),
			(255, 245, 238) => Ok(Named::Seashell),
			(160, 82, 45) => Ok(Named::Sienna),
			(192, 192, 192) => Ok(Named::Silver),
			(135, 206, 235) => Ok(Named::Skyblue),
			(106, 90, 205) => Ok(Named::Slateblue),
			(112, 128, 144) => Ok(Named::Slategray),
			(255, 250, 250) => Ok(Named::Snow),
			(0, 255, 127) => Ok(Named::Springgreen),
			(70, 130, 180) => Ok(Named::Steelblue),
			(210, 180, 140) => Ok(Named::Tan),
			(0, 128, 128) => Ok(Named::Teal),
			(216, 191, 216) => Ok(Named::Thistle),
			(255, 99, 71) => Ok(Named::Tomato),
			(64, 224, 208) => Ok(Named::Turquoise),
			(238, 130, 238) => Ok(Named::Violet),
			(245, 222, 179) => Ok(Named::Wheat),
			(255, 255, 255) => Ok(Named::White),
			(245, 245, 245) => Ok(Named::Whitesmoke),
			(255, 255, 0) => Ok(Named::Yellow),
			(154, 205, 50) => Ok(Named::Yellowgreen),
			_ => Err(ToNamedError::NoMatchingName),
		}
	}
}
