Color

Struct Color 

Source
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: f64

Red component (0.0 to 1.0).

§g: f64

Green component (0.0 to 1.0).

§b: f64

Blue component (0.0 to 1.0).

§a: f64

Alpha component (0.0 = transparent, 1.0 = opaque).

Implementations§

Source§

impl Color

Source

pub const TRANSPARENT: Self

Transparent (fully transparent black).

Source

pub const BLACK: Self

Black.

Source

pub const WHITE: Self

White.

Source

pub const RED: Self

Red.

Source

pub const GREEN: Self

Green.

Source

pub const BLUE: Self

Blue.

Source

pub const YELLOW: Self

Yellow.

Source

pub const CYAN: Self

Cyan.

Source

pub const MAGENTA: Self

Magenta.

Source

pub const ORANGE: Self

Orange.

Source

pub const PINK: Self

Pink.

Source

pub const PURPLE: Self

Purple.

Source

pub const DARK_GRAY: Self

Dark gray (25% intensity).

Source

pub const GRAY: Self

Gray (50% intensity).

Source

pub const LIGHT_GRAY: Self

Light gray (75% intensity).

Source

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).

Source

pub const fn rgb(r: f64, g: f64, b: f64) -> Self

Create a new opaque color from RGB components (0.0 to 1.0).

Source

pub fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Self

Create a color from 8-bit RGBA components (0 to 255).

Source

pub fn rgb8(r: u8, g: u8, b: u8) -> Self

Create an opaque color from 8-bit RGB components (0 to 255).

Source

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.

Source

pub const fn gray(intensity: f64) -> Self

Create a grayscale color with the given intensity (0.0 to 1.0).

Source

pub const fn gray_alpha(intensity: f64, alpha: f64) -> Self

Create a grayscale color with alpha.

Source

pub const fn with_alpha(self, alpha: f64) -> Self

Return a new color with the specified alpha component.

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Color

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&Color> for CFRetained<CGColor>

Source§

fn from(c: &Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for CFRetained<CGColor>

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Color

Source§

fn eq(&self, other: &Color) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Color

Source§

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 UnwindSafe for Color

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,