pub struct Color {
pub r: f64,
pub g: f64,
pub b: f64,
pub a: f64,
}Expand description
RGBA color (components 0.0–1.0).
Converts to CGColor automatically via Into.
Fields§
§r: f64Red component (0.0 to 1.0).
g: f64Green component (0.0 to 1.0).
b: f64Blue component (0.0 to 1.0).
a: f64Alpha component (0.0 = transparent, 1.0 = opaque).
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Self
pub const TRANSPARENT: Self
Transparent (fully transparent black).
Sourcepub const LIGHT_GRAY: Self
pub const LIGHT_GRAY: Self
Light gray (75% intensity).
Sourcepub const fn rgba(r: f64, g: f64, b: f64, a: f64) -> Self
pub const fn rgba(r: f64, g: f64, b: f64, a: f64) -> Self
Create a new color from RGBA components (0.0 to 1.0).
Sourcepub const fn rgb(r: f64, g: f64, b: f64) -> Self
pub const fn rgb(r: f64, g: f64, b: f64) -> Self
Create a new opaque color from RGB components (0.0 to 1.0).
Sourcepub fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
Create a color from 8-bit RGBA components (0 to 255).
Sourcepub fn rgb8(r: u8, g: u8, b: u8) -> Self
pub fn rgb8(r: u8, g: u8, b: u8) -> Self
Create an opaque color from 8-bit RGB components (0 to 255).
Sourcepub fn from_hex(hex: &str) -> Option<Self>
pub fn from_hex(hex: &str) -> Option<Self>
Create a color from a hex string (e.g., “#FF0000” or “FF0000”).
Supports 6-character (RGB) and 8-character (RGBA) hex strings.
Sourcepub const fn gray(intensity: f64) -> Self
pub const fn gray(intensity: f64) -> Self
Create a grayscale color with the given intensity (0.0 to 1.0).
Sourcepub const fn gray_alpha(intensity: f64, alpha: f64) -> Self
pub const fn gray_alpha(intensity: f64, alpha: f64) -> Self
Create a grayscale color with alpha.
Sourcepub const fn with_alpha(self, alpha: f64) -> Self
pub const fn with_alpha(self, alpha: f64) -> Self
Return a new color with the specified alpha component.