#[cfg(all(windows, feature = "d2d"))]
use winapi::um::d2dbasetypes::D2D_COLOR_F;
mod trie;
#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde_derive", derive(Serialize, Deserialize))]
#[repr(C)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
impl Color {
#[inline]
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Color {
Color { r, g, b, a }
}
#[inline]
pub fn from_u32(rgb: u32, a: f32) -> Color {
Color {
r: ((rgb >> 16) & 0xFF) as f32 / 255.0,
g: ((rgb >> 8) & 0xFF) as f32 / 255.0,
b: ((rgb >> 0) & 0xFF) as f32 / 255.0,
a: a,
}
}
#[inline]
pub fn lerp(&self, other: &Color, t: f32) -> Color {
let ti = 1.0 - t;
Color {
r: self.r * ti + other.r * t,
g: self.g * ti + other.g * t,
b: self.b * ti + other.b * t,
a: self.a * ti + other.a * t,
}
}
pub fn lookup(name: &str) -> Option<Color> {
let mut node = &trie::NODES[0];
let mut name = name.as_bytes();
'iter: while !name.is_empty() {
let idx = match name[0] {
b @ b'a'..=b'z' => b - b'a' + 1,
b @ b'A'..=b'Z' => b - b'A' + 1,
_ => 0,
};
let s = node.children.0 as usize;
let e = s + node.children.1 as usize;
let list = &trie::CHILDREN[s..e];
for &(b, nid) in list {
if idx == b {
node = &trie::NODES[nid as usize];
name = &name[1..];
continue 'iter;
}
}
return None;
}
node.color.map(|c| trie::COLORS[c as usize])
}
pub fn from_str_rgba(s: &str) -> Result<Color, ColorParseError> {
match Self::from_str_raw(s) {
ColorParseResult::BuiltinColor(color) => Ok(color),
ColorParseResult::Data(data, false) => Ok(Color {
r: data[0] as f32 / 255.0,
g: data[1] as f32 / 255.0,
b: data[2] as f32 / 255.0,
a: 1.0,
}),
ColorParseResult::Data(data, true) => Ok(Color {
r: data[0] as f32 / 255.0,
g: data[1] as f32 / 255.0,
b: data[2] as f32 / 255.0,
a: data[3] as f32 / 255.0,
}),
ColorParseResult::ColorNotFound => Err(ColorParseError::ColorNotFound),
ColorParseResult::BadHexFormat => Err(ColorParseError::BadHexFormat),
}
}
pub fn from_str_argb(s: &str) -> Result<Color, ColorParseError> {
match Self::from_str_raw(s) {
ColorParseResult::BuiltinColor(color) => Ok(color),
ColorParseResult::Data(data, false) => Ok(Color {
r: data[0] as f32 / 255.0,
g: data[1] as f32 / 255.0,
b: data[2] as f32 / 255.0,
a: 1.0,
}),
ColorParseResult::Data(data, true) => Ok(Color {
a: data[0] as f32 / 255.0,
r: data[1] as f32 / 255.0,
g: data[2] as f32 / 255.0,
b: data[3] as f32 / 255.0,
}),
ColorParseResult::ColorNotFound => Err(ColorParseError::ColorNotFound),
ColorParseResult::BadHexFormat => Err(ColorParseError::BadHexFormat),
}
}
fn from_str_raw(mut s: &str) -> ColorParseResult {
s = s.trim();
if let Some(color) = Color::lookup(s) {
return ColorParseResult::BuiltinColor(color);
}
if s.starts_with('#') {
s = s.trim_start_matches('#');
if !s.chars().all(|c| c.is_digit(16)) {
return ColorParseResult::BadHexFormat;
}
} else if !s.is_empty() || !s.chars().all(|c| c.is_digit(16)) {
return ColorParseResult::ColorNotFound;
}
if s.len() > 8 {
return ColorParseResult::BadHexFormat;
}
let data = u32::from_str_radix(s, 16).unwrap();
let byt = |i: u32| ((data >> (i * 8)) & 0xFF) as u8;
let nib = |i: u32| ((data >> (i * 4)) & 0xF) as u8;
let dnib = |i| nib(i) | (nib(i) << 4);
match s.len() {
3 => ColorParseResult::Data([dnib(2), dnib(1), dnib(0), 0], false),
4 => ColorParseResult::Data([dnib(3), dnib(2), dnib(1), dnib(0)], true),
6 => ColorParseResult::Data([byt(2), byt(1), byt(0), 0], false),
8 => ColorParseResult::Data([byt(3), byt(2), byt(1), byt(0)], true),
_ => ColorParseResult::BadHexFormat,
}
}
}
enum ColorParseResult {
BuiltinColor(Color),
Data([u8; 4], bool),
ColorNotFound,
BadHexFormat,
}
#[cfg(test)]
#[test]
fn color_lookups() {
assert_eq!(Color::lookup("blue"), Some(Color::BLUE));
assert_eq!(Color::lookup("BLUE"), Some(Color::BLUE));
assert_eq!(Color::lookup("BlUe"), Some(Color::BLUE));
assert_eq!(Color::lookup("bLuE"), Some(Color::BLUE));
assert_eq!(Color::lookup("bluee"), None);
assert_eq!(Color::lookup("blu"), None);
assert_eq!(Color::lookup("alice-blue"), Some(Color::ALICE_BLUE));
assert_eq!(Color::lookup("alice blue"), Some(Color::ALICE_BLUE));
assert_eq!(Color::lookup("alice_blue"), Some(Color::ALICE_BLUE));
assert_eq!(Color::lookup("alice.blue"), Some(Color::ALICE_BLUE));
assert_eq!(Color::lookup("alice+blue"), Some(Color::ALICE_BLUE));
assert_eq!(Color::lookup("alice-blue-"), None);
}
#[derive(Debug)]
pub enum ColorParseError {
ColorNotFound,
BadHexFormat,
}
impl std::fmt::Display for ColorParseError {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(fmt, "{}", std::error::Error::description(self))
}
}
impl std::error::Error for ColorParseError {
fn description(&self) -> &str {
match self {
ColorParseError::ColorNotFound => "Color not found",
ColorParseError::BadHexFormat => "Bad hex format",
}
}
}
impl std::str::FromStr for Color {
type Err = ColorParseError;
fn from_str(s: &str) -> Result<Color, ColorParseError> {
Color::from_str_rgba(s)
}
}
impl Default for Color {
#[inline]
fn default() -> Self {
Color::from(0)
}
}
impl<'a> From<&'a Color> for Color {
#[inline]
fn from(color: &'a Color) -> Color {
*color
}
}
impl From<u32> for Color {
#[inline]
fn from(rgb: u32) -> Color {
Color::from_u32(rgb, 1.0)
}
}
impl From<(u32, f32)> for Color {
#[inline]
fn from((rgb, a): (u32, f32)) -> Color {
Color::from_u32(rgb, a)
}
}
#[cfg(all(windows, feature = "d2d"))]
impl From<Color> for D2D_COLOR_F {
#[inline]
fn from(color: Color) -> D2D_COLOR_F {
let Color { r, g, b, a } = color;
D2D_COLOR_F { r, g, b, a }
}
}
#[cfg(all(windows, feature = "d2d"))]
impl From<D2D_COLOR_F> for Color {
#[inline]
fn from(color: D2D_COLOR_F) -> Color {
let D2D_COLOR_F { r, g, b, a } = color;
Color { r, g, b, a }
}
}
macro_rules! define_color {
($r:expr, $g:expr, $b:expr) => {
Color {
r: $r as f32 / 255.0,
g: $g as f32 / 255.0,
b: $b as f32 / 255.0,
a: 1.0,
}
};
}
pub const ALICE_BLUE: Color = define_color!(0xF0, 0xF8, 0xFF);
pub const ANTIQUE_WHITE: Color = define_color!(0xFA, 0xEB, 0xD7);
pub const AQUA: Color = define_color!(0x00, 0xFF, 0xFF);
pub const AQUAMARINE: Color = define_color!(0x7F, 0xFF, 0xD4);
pub const AZURE: Color = define_color!(0xF0, 0xFF, 0xFF);
pub const BEIGE: Color = define_color!(0xF5, 0xF5, 0xDC);
pub const BISQUE: Color = define_color!(0xFF, 0xE4, 0xC4);
pub const BLACK: Color = define_color!(0x00, 0x00, 0x00);
pub const BLANCHED_ALMOND: Color = define_color!(0xFF, 0xEB, 0xCD);
pub const BLUE: Color = define_color!(0x00, 0x00, 0xFF);
pub const BLUE_VIOLET: Color = define_color!(0x8A, 0x2B, 0xE2);
pub const BROWN: Color = define_color!(0xA5, 0x2A, 0x2A);
pub const BURLY_WOOD: Color = define_color!(0xDE, 0xB8, 0x87);
pub const CADET_BLUE: Color = define_color!(0x5F, 0x9E, 0xA0);
pub const CHARTREUSE: Color = define_color!(0x7F, 0xFF, 0x00);
pub const CHOCOLATE: Color = define_color!(0xD2, 0x69, 0x1E);
pub const CORAL: Color = define_color!(0xFF, 0x7F, 0x50);
pub const CORNFLOWER_BLUE: Color = define_color!(0x64, 0x95, 0xED);
pub const CORNSILK: Color = define_color!(0xFF, 0xF8, 0xDC);
pub const CRIMSON: Color = define_color!(0xDC, 0x14, 0x3C);
pub const CYAN: Color = define_color!(0x00, 0xFF, 0xFF);
pub const DARK_BLUE: Color = define_color!(0x00, 0x00, 0x8B);
pub const DARK_CYAN: Color = define_color!(0x00, 0x8B, 0x8B);
pub const DARK_GOLDENROD: Color = define_color!(0xB8, 0x86, 0x0B);
pub const DARK_GRAY: Color = define_color!(0xA9, 0xA9, 0xA9);
pub const DARK_GREEN: Color = define_color!(0x00, 0x64, 0x00);
pub const DARK_KHAKI: Color = define_color!(0xBD, 0xB7, 0x6B);
pub const DARK_MAGENTA: Color = define_color!(0x8B, 0x00, 0x8B);
pub const DARK_OLIVEGREEN: Color = define_color!(0x55, 0x6B, 0x2F);
pub const DARK_ORANGE: Color = define_color!(0xFF, 0x8C, 0x00);
pub const DARK_ORCHID: Color = define_color!(0x99, 0x32, 0xCC);
pub const DARK_RED: Color = define_color!(0x8B, 0x00, 0x00);
pub const DARK_SALMON: Color = define_color!(0xE9, 0x96, 0x7A);
pub const DARK_SEAGREEN: Color = define_color!(0x8F, 0xBC, 0x8F);
pub const DARK_SLATEBLUE: Color = define_color!(0x48, 0x3D, 0x8B);
pub const DARK_SLATEGRAY: Color = define_color!(0x2F, 0x4F, 0x4F);
pub const DARK_TURQUOISE: Color = define_color!(0x00, 0xCE, 0xD1);
pub const DARK_VIOLET: Color = define_color!(0x94, 0x00, 0xD3);
pub const DEEP_PINK: Color = define_color!(0xFF, 0x14, 0x93);
pub const DEEP_SKYBLUE: Color = define_color!(0x00, 0xBF, 0xFF);
pub const DIM_GRAY: Color = define_color!(0x69, 0x69, 0x69);
pub const DODGER_BLUE: Color = define_color!(0x1E, 0x90, 0xFF);
pub const FIREBRICK: Color = define_color!(0xB2, 0x22, 0x22);
pub const FLORAL_WHITE: Color = define_color!(0xFF, 0xFA, 0xF0);
pub const FOREST_GREEN: Color = define_color!(0x22, 0x8B, 0x22);
pub const FUCHSIA: Color = define_color!(0xFF, 0x00, 0xFF);
pub const GAINSBORO: Color = define_color!(0xDC, 0xDC, 0xDC);
pub const GHOST_WHITE: Color = define_color!(0xF8, 0xF8, 0xFF);
pub const GOLD: Color = define_color!(0xFF, 0xD7, 0x00);
pub const GOLDENROD: Color = define_color!(0xDA, 0xA5, 0x20);
pub const GRAY: Color = define_color!(0x80, 0x80, 0x80);
pub const GREEN: Color = define_color!(0x00, 0x80, 0x00);
pub const GREEN_YELLOW: Color = define_color!(0xAD, 0xFF, 0x2F);
pub const HONEYDEW: Color = define_color!(0xF0, 0xFF, 0xF0);
pub const HOT_PINK: Color = define_color!(0xFF, 0x69, 0xB4);
pub const INDIAN_RED: Color = define_color!(0xCD, 0x5C, 0x5C);
pub const INDIGO: Color = define_color!(0x4B, 0x00, 0x82);
pub const IVORY: Color = define_color!(0xFF, 0xFF, 0xF0);
pub const KHAKI: Color = define_color!(0xF0, 0xE6, 0x8C);
pub const LAVENDER: Color = define_color!(0xE6, 0xE6, 0xFA);
pub const LAVENDER_BLUSH: Color = define_color!(0xFF, 0xF0, 0xF5);
pub const LAWN_GREEN: Color = define_color!(0x7C, 0xFC, 0x00);
pub const LEMON_CHIFFON: Color = define_color!(0xFF, 0xFA, 0xCD);
pub const LIGHT_BLUE: Color = define_color!(0xAD, 0xD8, 0xE6);
pub const LIGHT_CORAL: Color = define_color!(0xF0, 0x80, 0x80);
pub const LIGHT_CYAN: Color = define_color!(0xE0, 0xFF, 0xFF);
pub const LIGHT_GOLDENRODYELLOW: Color = define_color!(0xFA, 0xFA, 0xD2);
pub const LIGHT_GREEN: Color = define_color!(0x90, 0xEE, 0x90);
pub const LIGHT_GRAY: Color = define_color!(0xD3, 0xD3, 0xD3);
pub const LIGHT_PINK: Color = define_color!(0xFF, 0xB6, 0xC1);
pub const LIGHT_SALMON: Color = define_color!(0xFF, 0xA0, 0x7A);
pub const LIGHT_SEAGREEN: Color = define_color!(0x20, 0xB2, 0xAA);
pub const LIGHT_SKYBLUE: Color = define_color!(0x87, 0xCE, 0xFA);
pub const LIGHT_SLATEGRAY: Color = define_color!(0x77, 0x88, 0x99);
pub const LIGHT_STEELBLUE: Color = define_color!(0xB0, 0xC4, 0xDE);
pub const LIGHT_YELLOW: Color = define_color!(0xFF, 0xFF, 0xE0);
pub const LIME: Color = define_color!(0x00, 0xFF, 0x00);
pub const LIME_GREEN: Color = define_color!(0x32, 0xCD, 0x32);
pub const LINEN: Color = define_color!(0xFA, 0xF0, 0xE6);
pub const MAGENTA: Color = define_color!(0xFF, 0x00, 0xFF);
pub const MAROON: Color = define_color!(0x80, 0x00, 0x00);
pub const MEDIUM_AQUAMARINE: Color = define_color!(0x66, 0xCD, 0xAA);
pub const MEDIUM_BLUE: Color = define_color!(0x00, 0x00, 0xCD);
pub const MEDIUM_ORCHID: Color = define_color!(0xBA, 0x55, 0xD3);
pub const MEDIUM_PURPLE: Color = define_color!(0x93, 0x70, 0xDB);
pub const MEDIUM_SEAGREEN: Color = define_color!(0x3C, 0xB3, 0x71);
pub const MEDIUM_SLATEBLUE: Color = define_color!(0x7B, 0x68, 0xEE);
pub const MEDIUM_SPRINGGREEN: Color = define_color!(0x00, 0xFA, 0x9A);
pub const MEDIUM_TURQUOISE: Color = define_color!(0x48, 0xD1, 0xCC);
pub const MEDIUM_VIOLETRED: Color = define_color!(0xC7, 0x15, 0x85);
pub const MIDNIGHT_BLUE: Color = define_color!(0x19, 0x19, 0x70);
pub const MINT_CREAM: Color = define_color!(0xF5, 0xFF, 0xFA);
pub const MISTY_ROSE: Color = define_color!(0xFF, 0xE4, 0xE1);
pub const MOCCASIN: Color = define_color!(0xFF, 0xE4, 0xB5);
pub const NAVAJO_WHITE: Color = define_color!(0xFF, 0xDE, 0xAD);
pub const NAVY: Color = define_color!(0x00, 0x00, 0x80);
pub const OLD_LACE: Color = define_color!(0xFD, 0xF5, 0xE6);
pub const OLIVE: Color = define_color!(0x80, 0x80, 0x00);
pub const OLIVE_DRAB: Color = define_color!(0x6B, 0x8E, 0x23);
pub const ORANGE: Color = define_color!(0xFF, 0xA5, 0x00);
pub const ORANGE_RED: Color = define_color!(0xFF, 0x45, 0x00);
pub const ORCHID: Color = define_color!(0xDA, 0x70, 0xD6);
pub const PALE_GOLDENROD: Color = define_color!(0xEE, 0xE8, 0xAA);
pub const PALE_GREEN: Color = define_color!(0x98, 0xFB, 0x98);
pub const PALE_TURQUOISE: Color = define_color!(0xAF, 0xEE, 0xEE);
pub const PALE_VIOLETRED: Color = define_color!(0xDB, 0x70, 0x93);
pub const PAPAYA_WHIP: Color = define_color!(0xFF, 0xEF, 0xD5);
pub const PEACH_PUFF: Color = define_color!(0xFF, 0xDA, 0xB9);
pub const PERU: Color = define_color!(0xCD, 0x85, 0x3F);
pub const PINK: Color = define_color!(0xFF, 0xC0, 0xCB);
pub const PLUM: Color = define_color!(0xDD, 0xA0, 0xDD);
pub const POWDER_BLUE: Color = define_color!(0xB0, 0xE0, 0xE6);
pub const PURPLE: Color = define_color!(0x80, 0x00, 0x80);
pub const RED: Color = define_color!(0xFF, 0x00, 0x00);
pub const ROSY_BROWN: Color = define_color!(0xBC, 0x8F, 0x8F);
pub const ROYAL_BLUE: Color = define_color!(0x41, 0x69, 0xE1);
pub const SADDLE_BROWN: Color = define_color!(0x8B, 0x45, 0x13);
pub const SALMON: Color = define_color!(0xFA, 0x80, 0x72);
pub const SANDY_BROWN: Color = define_color!(0xF4, 0xA4, 0x60);
pub const SEA_GREEN: Color = define_color!(0x2E, 0x8B, 0x57);
pub const SEA_SHELL: Color = define_color!(0xFF, 0xF5, 0xEE);
pub const SIENNA: Color = define_color!(0xA0, 0x52, 0x2D);
pub const SILVER: Color = define_color!(0xC0, 0xC0, 0xC0);
pub const SKY_BLUE: Color = define_color!(0x87, 0xCE, 0xEB);
pub const SLATE_BLUE: Color = define_color!(0x6A, 0x5A, 0xCD);
pub const SLATE_GRAY: Color = define_color!(0x70, 0x80, 0x90);
pub const SNOW: Color = define_color!(0xFF, 0xFA, 0xFA);
pub const SPRING_GREEN: Color = define_color!(0x00, 0xFF, 0x7F);
pub const STEEL_BLUE: Color = define_color!(0x46, 0x82, 0xB4);
pub const TAN: Color = define_color!(0xD2, 0xB4, 0x8C);
pub const TEAL: Color = define_color!(0x00, 0x80, 0x80);
pub const THISTLE: Color = define_color!(0xD8, 0xBF, 0xD8);
pub const TOMATO: Color = define_color!(0xFF, 0x63, 0x47);
pub const TURQUOISE: Color = define_color!(0x40, 0xE0, 0xD0);
pub const VIOLET: Color = define_color!(0xEE, 0x82, 0xEE);
pub const WHEAT: Color = define_color!(0xF5, 0xDE, 0xB3);
pub const WHITE: Color = define_color!(0xFF, 0xFF, 0xFF);
pub const WHITE_SMOKE: Color = define_color!(0xF5, 0xF5, 0xF5);
pub const YELLOW: Color = define_color!(0xFF, 0xFF, 0x00);
pub const YELLOW_GREEN: Color = define_color!(0x9A, 0xCD, 0x32);
impl Color {
pub const ALICE_BLUE: Color = ALICE_BLUE;
pub const ANTIQUE_WHITE: Color = ANTIQUE_WHITE;
pub const AQUA: Color = AQUA;
pub const AQUAMARINE: Color = AQUAMARINE;
pub const AZURE: Color = AZURE;
pub const BEIGE: Color = BEIGE;
pub const BISQUE: Color = BISQUE;
pub const BLACK: Color = BLACK;
pub const BLANCHED_ALMOND: Color = BLANCHED_ALMOND;
pub const BLUE: Color = BLUE;
pub const BLUE_VIOLET: Color = BLUE_VIOLET;
pub const BROWN: Color = BROWN;
pub const BURLY_WOOD: Color = BURLY_WOOD;
pub const CADET_BLUE: Color = CADET_BLUE;
pub const CHARTREUSE: Color = CHARTREUSE;
pub const CHOCOLATE: Color = CHOCOLATE;
pub const CORAL: Color = CORAL;
pub const CORNFLOWER_BLUE: Color = CORNFLOWER_BLUE;
pub const CORNSILK: Color = CORNSILK;
pub const CRIMSON: Color = CRIMSON;
pub const CYAN: Color = CYAN;
pub const DARK_BLUE: Color = DARK_BLUE;
pub const DARK_CYAN: Color = DARK_CYAN;
pub const DARK_GOLDENROD: Color = DARK_GOLDENROD;
pub const DARK_GRAY: Color = DARK_GRAY;
pub const DARK_GREEN: Color = DARK_GREEN;
pub const DARK_KHAKI: Color = DARK_KHAKI;
pub const DARK_MAGENTA: Color = DARK_MAGENTA;
pub const DARK_OLIVEGREEN: Color = DARK_OLIVEGREEN;
pub const DARK_ORANGE: Color = DARK_ORANGE;
pub const DARK_ORCHID: Color = DARK_ORCHID;
pub const DARK_RED: Color = DARK_RED;
pub const DARK_SALMON: Color = DARK_SALMON;
pub const DARK_SEAGREEN: Color = DARK_SEAGREEN;
pub const DARK_SLATEBLUE: Color = DARK_SLATEBLUE;
pub const DARK_SLATEGRAY: Color = DARK_SLATEGRAY;
pub const DARK_TURQUOISE: Color = DARK_TURQUOISE;
pub const DARK_VIOLET: Color = DARK_VIOLET;
pub const DEEP_PINK: Color = DEEP_PINK;
pub const DEEP_SKYBLUE: Color = DEEP_SKYBLUE;
pub const DIM_GRAY: Color = DIM_GRAY;
pub const DODGER_BLUE: Color = DODGER_BLUE;
pub const FIREBRICK: Color = FIREBRICK;
pub const FLORAL_WHITE: Color = FLORAL_WHITE;
pub const FOREST_GREEN: Color = FOREST_GREEN;
pub const FUCHSIA: Color = FUCHSIA;
pub const GAINSBORO: Color = GAINSBORO;
pub const GHOST_WHITE: Color = GHOST_WHITE;
pub const GOLD: Color = GOLD;
pub const GOLDENROD: Color = GOLDENROD;
pub const GRAY: Color = GRAY;
pub const GREEN: Color = GREEN;
pub const GREEN_YELLOW: Color = GREEN_YELLOW;
pub const HONEYDEW: Color = HONEYDEW;
pub const HOT_PINK: Color = HOT_PINK;
pub const INDIAN_RED: Color = INDIAN_RED;
pub const INDIGO: Color = INDIGO;
pub const IVORY: Color = IVORY;
pub const KHAKI: Color = KHAKI;
pub const LAVENDER: Color = LAVENDER;
pub const LAVENDER_BLUSH: Color = LAVENDER_BLUSH;
pub const LAWN_GREEN: Color = LAWN_GREEN;
pub const LEMON_CHIFFON: Color = LEMON_CHIFFON;
pub const LIGHT_BLUE: Color = LIGHT_BLUE;
pub const LIGHT_CORAL: Color = LIGHT_CORAL;
pub const LIGHT_CYAN: Color = LIGHT_CYAN;
pub const LIGHT_GOLDENRODYELLOW: Color = LIGHT_GOLDENRODYELLOW;
pub const LIGHT_GREEN: Color = LIGHT_GREEN;
pub const LIGHT_GRAY: Color = LIGHT_GRAY;
pub const LIGHT_PINK: Color = LIGHT_PINK;
pub const LIGHT_SALMON: Color = LIGHT_SALMON;
pub const LIGHT_SEAGREEN: Color = LIGHT_SEAGREEN;
pub const LIGHT_SKYBLUE: Color = LIGHT_SKYBLUE;
pub const LIGHT_SLATEGRAY: Color = LIGHT_SLATEGRAY;
pub const LIGHT_STEELBLUE: Color = LIGHT_STEELBLUE;
pub const LIGHT_YELLOW: Color = LIGHT_YELLOW;
pub const LIME: Color = LIME;
pub const LIME_GREEN: Color = LIME_GREEN;
pub const LINEN: Color = LINEN;
pub const MAGENTA: Color = MAGENTA;
pub const MAROON: Color = MAROON;
pub const MEDIUM_AQUAMARINE: Color = MEDIUM_AQUAMARINE;
pub const MEDIUM_BLUE: Color = MEDIUM_BLUE;
pub const MEDIUM_ORCHID: Color = MEDIUM_ORCHID;
pub const MEDIUM_PURPLE: Color = MEDIUM_PURPLE;
pub const MEDIUM_SEAGREEN: Color = MEDIUM_SEAGREEN;
pub const MEDIUM_SLATEBLUE: Color = MEDIUM_SLATEBLUE;
pub const MEDIUM_SPRINGGREEN: Color = MEDIUM_SPRINGGREEN;
pub const MEDIUM_TURQUOISE: Color = MEDIUM_TURQUOISE;
pub const MEDIUM_VIOLETRED: Color = MEDIUM_VIOLETRED;
pub const MIDNIGHT_BLUE: Color = MIDNIGHT_BLUE;
pub const MINT_CREAM: Color = MINT_CREAM;
pub const MISTY_ROSE: Color = MISTY_ROSE;
pub const MOCCASIN: Color = MOCCASIN;
pub const NAVAJO_WHITE: Color = NAVAJO_WHITE;
pub const NAVY: Color = NAVY;
pub const OLD_LACE: Color = OLD_LACE;
pub const OLIVE: Color = OLIVE;
pub const OLIVE_DRAB: Color = OLIVE_DRAB;
pub const ORANGE: Color = ORANGE;
pub const ORANGE_RED: Color = ORANGE_RED;
pub const ORCHID: Color = ORCHID;
pub const PALE_GOLDENROD: Color = PALE_GOLDENROD;
pub const PALE_GREEN: Color = PALE_GREEN;
pub const PALE_TURQUOISE: Color = PALE_TURQUOISE;
pub const PALE_VIOLETRED: Color = PALE_VIOLETRED;
pub const PAPAYA_WHIP: Color = PAPAYA_WHIP;
pub const PEACH_PUFF: Color = PEACH_PUFF;
pub const PERU: Color = PERU;
pub const PINK: Color = PINK;
pub const PLUM: Color = PLUM;
pub const POWDER_BLUE: Color = POWDER_BLUE;
pub const PURPLE: Color = PURPLE;
pub const RED: Color = RED;
pub const ROSY_BROWN: Color = ROSY_BROWN;
pub const ROYAL_BLUE: Color = ROYAL_BLUE;
pub const SADDLE_BROWN: Color = SADDLE_BROWN;
pub const SALMON: Color = SALMON;
pub const SANDY_BROWN: Color = SANDY_BROWN;
pub const SEA_GREEN: Color = SEA_GREEN;
pub const SEA_SHELL: Color = SEA_SHELL;
pub const SIENNA: Color = SIENNA;
pub const SILVER: Color = SILVER;
pub const SKY_BLUE: Color = SKY_BLUE;
pub const SLATE_BLUE: Color = SLATE_BLUE;
pub const SLATE_GRAY: Color = SLATE_GRAY;
pub const SNOW: Color = SNOW;
pub const SPRING_GREEN: Color = SPRING_GREEN;
pub const STEEL_BLUE: Color = STEEL_BLUE;
pub const TAN: Color = TAN;
pub const TEAL: Color = TEAL;
pub const THISTLE: Color = THISTLE;
pub const TOMATO: Color = TOMATO;
pub const TURQUOISE: Color = TURQUOISE;
pub const VIOLET: Color = VIOLET;
pub const WHEAT: Color = WHEAT;
pub const WHITE: Color = WHITE;
pub const WHITE_SMOKE: Color = WHITE_SMOKE;
pub const YELLOW: Color = YELLOW;
pub const YELLOW_GREEN: Color = YELLOW_GREEN;
}
#[cfg(all(test, windows, feature = "d2d"))]
#[test]
fn color_d2d_bin_compat() {
use std::mem::size_of_val;
fn ptr_eq<T>(a: &T, b: &T) -> bool {
(a as *const T) == (b as *const T)
}
let col = Color::from(0);
let d2d = unsafe { &*((&col) as *const _ as *const D2D_COLOR_F) };
assert!(ptr_eq(&col.r, &d2d.r));
assert!(ptr_eq(&col.g, &d2d.g));
assert!(ptr_eq(&col.b, &d2d.b));
assert!(ptr_eq(&col.a, &d2d.a));
assert_eq!(size_of_val(&col), size_of_val(d2d));
}