''
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//! The 16 EGA/VGA named colors, the shared source of truth for both the Rhai color
|
||||
//! constants (see [`crate::script`]) and the editor's color picker, so the two never
|
||||
//! drift apart.
|
||||
|
||||
use color::Rgba8;
|
||||
|
||||
/// Builds an opaque [`Rgba8`] from RGB bytes (const-friendly helper for the table).
|
||||
const fn rgb(r: u8, g: u8, b: u8) -> Rgba8 {
|
||||
Rgba8 { r, g, b, a: 255 }
|
||||
}
|
||||
|
||||
/// The 16 EGA/VGA palette colors as `(name, color)` pairs, in palette order.
|
||||
///
|
||||
/// Used to register the Rhai `Black`/`Blue`/… constants and to populate the color
|
||||
/// picker's named-swatch strip. The names match the Rhai constants exactly.
|
||||
pub const NAMED_COLORS: [(&str, Rgba8); 16] = [
|
||||
("Black", rgb(0x00, 0x00, 0x00)),
|
||||
("Blue", rgb(0x00, 0x00, 0xAA)),
|
||||
("Green", rgb(0x00, 0xAA, 0x00)),
|
||||
("Cyan", rgb(0x00, 0xAA, 0xAA)),
|
||||
("Red", rgb(0xAA, 0x00, 0x00)),
|
||||
("Magenta", rgb(0xAA, 0x00, 0xAA)),
|
||||
("Brown", rgb(0xAA, 0x55, 0x00)),
|
||||
("LightGray", rgb(0xAA, 0xAA, 0xAA)),
|
||||
("DarkGray", rgb(0x55, 0x55, 0x55)),
|
||||
("BrightBlue", rgb(0x55, 0x55, 0xFF)),
|
||||
("BrightGreen", rgb(0x55, 0xFF, 0x55)),
|
||||
("BrightCyan", rgb(0x55, 0xFF, 0xFF)),
|
||||
("BrightRed", rgb(0xFF, 0x55, 0x55)),
|
||||
("BrightMagenta", rgb(0xFF, 0x55, 0xFF)),
|
||||
("Yellow", rgb(0xFF, 0xFF, 0x55)),
|
||||
("White", rgb(0xFF, 0xFF, 0xFF)),
|
||||
];
|
||||
Reference in New Issue
Block a user