pub struct Color { /* private fields */ }Expand description
Represents a color with various conversion capabilities
Implementations§
Source§impl Color
impl Color
Sourcepub fn from_hex(hex: &str) -> Result<Self, ColorError>
pub fn from_hex(hex: &str) -> Result<Self, ColorError>
Create a Color from a hex string (e.g., “#FF5733” or “FF5733”)
Sourcepub fn from_hsl(h: f32, s: f32, l: f32) -> Result<Self, ColorError>
pub fn from_hsl(h: f32, s: f32, l: f32) -> Result<Self, ColorError>
Create a Color from HSL values
Sourcepub fn from_minecraft_code(code: &str) -> Result<Self, ColorError>
pub fn from_minecraft_code(code: &str) -> Result<Self, ColorError>
Create a Color from Minecraft color code (e.g., “§c”, “&4”, “&#FF5733”)
Sourcepub fn from_hsv(h: f32, s: f32, v: f32) -> Result<Self, ColorError>
pub fn from_hsv(h: f32, s: f32, v: f32) -> Result<Self, ColorError>
Create a Color from HSV values
Sourcepub fn from_cmyk(c: f32, m: f32, y: f32, k: f32) -> Result<Self, ColorError>
pub fn from_cmyk(c: f32, m: f32, y: f32, k: f32) -> Result<Self, ColorError>
Create a Color from CMYK values
Sourcepub fn to_hex_alpha(&self) -> String
pub fn to_hex_alpha(&self) -> String
Convert to hex string with alpha
Sourcepub fn contrasting_text_color(&self) -> Color
pub fn contrasting_text_color(&self) -> Color
Get a contrasting color (black or white) for text overlay
Sourcepub fn to_minecraft_code(&self) -> String
pub fn to_minecraft_code(&self) -> String
Convert to Minecraft legacy color code (closest match)
Sourcepub fn to_minecraft_hex(&self) -> String
pub fn to_minecraft_hex(&self) -> String
Convert to Minecraft modern hex color code format
Sourcepub fn to_minecraft_hex_alt(&self) -> String
pub fn to_minecraft_hex_alt(&self) -> String
Convert to Minecraft alternate hex format (&x&R&R&G&G&B&B)
Source§impl Color
impl Color
pub const BLACK: Color
pub const WHITE: Color
pub const RED: Color
pub const GREEN: Color
pub const BLUE: Color
pub const YELLOW: Color
pub const CYAN: Color
pub const MAGENTA: Color
pub const MC_BLACK: Color
pub const MC_DARK_BLUE: Color
pub const MC_DARK_GREEN: Color
pub const MC_DARK_AQUA: Color
pub const MC_DARK_RED: Color
pub const MC_DARK_PURPLE: Color
pub const MC_GOLD: Color
pub const MC_GRAY: Color
pub const MC_DARK_GRAY: Color
pub const MC_BLUE: Color
pub const MC_GREEN: Color
pub const MC_AQUA: Color
pub const MC_RED: Color
pub const MC_LIGHT_PURPLE: Color
pub const MC_YELLOW: Color
pub const MC_WHITE: Color
Trait Implementations§
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more