Color

Struct Color 

Source
#[repr(C)]
pub struct Color { pub red: f32, pub green: f32, pub blue: f32, pub alpha: f32, }
Expand description

Basic color representation

Fields§

§red: f32

Red component

§green: f32

Green component

§blue: f32

Blue component

§alpha: f32

Alpha component

Implementations§

Source§

impl Color

Source

pub fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Self

Create color with floating point components

Source

pub fn rgb(red: u8, green: u8, blue: u8) -> Self

Create solid color with byte components

Source

pub fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Self

Create color with byte components

Source

pub fn hsl(hue: f32, saturation: f32, lightness: f32) -> Self

Create solid color with using hsl color space

Source

pub fn hsla(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Self

Create solid color with using hsl color space and alpha component

Source

pub fn hsv(hue: f32, saturation: f32, value: f32) -> Self

Create solid color with using hsv color space

Source

pub fn hsva(hue: f32, saturation: f32, value: f32, alpha: f32) -> Self

Create solid color with using hsv color space and alpha component

Source

pub fn cmyk(cyan: f32, magenta: f32, yellow: f32, key: f32) -> Self

Create solid color with using cmyk color space

Source

pub fn cmyka(cyan: f32, magenta: f32, yellow: f32, key: f32, alpha: f32) -> Self

Create solid color with using cmyk color space and alpha component

Source

pub fn cmy(cyan: f32, magenta: f32, yellow: f32) -> Self

Create solid color with using cmy color space

Source

pub fn cmya(cyan: f32, magenta: f32, yellow: f32, alpha: f32) -> Self

Create solid color with using cmy color space and alpha component

Source

pub fn RGB(red: u8, green: u8, blue: u8) -> Self

👎Deprecated

Create solid color with using rgb color space

Source

pub fn RGBA(red: u8, green: u8, blue: u8, alpha: u8) -> Self

👎Deprecated

Create solid color with using lab rgb space and alpha component

Source

pub fn HSL(hue: f32, saturation: f32, lightness: f32) -> Self

👎Deprecated

Create solid color with using hsl color space

Source

pub fn HSV(hue: f32, saturation: f32, value: f32) -> Self

👎Deprecated

Create solid color with using hsv color space

Source

pub fn CMYK(cyan: f32, magenta: f32, yellow: f32, key: f32) -> Self

👎Deprecated

Create solid color with using cmyk color space

Source

pub fn CMY(cyan: f32, magenta: f32, yellow: f32) -> Self

👎Deprecated

Create solid color with using cmy color space

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

Source§

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

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

impl From<Alpha<RgbColor>> for Color

Source§

fn from(from_color_with_alpha: Alpha<RgbColor>) -> Self

Converts to this type from the input type.
Source§

impl From<CmyColor> for Color

Source§

fn from(_: CmyColor) -> Self

Converts to this type from the input type.
Source§

impl From<CmykColor> for Color

Source§

fn from(cmyk: CmykColor) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for CmyColor

Source§

fn from(_: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for CmykColor

Source§

fn from(rgb: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for HslColor

Source§

fn from(rgb: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for HsvColor

Source§

fn from(rgb: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for RgbColor

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for RgbaColor

Source§

fn from(color: Color) -> Self

Converts to this type from the input type.
Source§

impl From<HslColor> for Color

Source§

fn from(hsl: HslColor) -> Self

Converts to this type from the input type.
Source§

impl From<HsvColor> for Color

Source§

fn from(hsv: HsvColor) -> Self

Converts to this type from the input type.
Source§

impl From<RgbColor> for Color

Source§

fn from(c: RgbColor) -> Self

Converts to this type from the input type.
Source§

impl From<RgbaColor> for Color

Source§

fn from(rgba: RgbaColor) -> Self

Converts to this type from the input type.
Source§

impl GetAlpha<Color> for Color

Source§

fn get_alpha(&self) -> f32

Retrieve the alpha component
Source§

fn get_opacity(&self) -> f32

Retrieve the alpha component as opacity
Source§

fn get_transparency(&self) -> f32

Retrieve the alpha component as transparency
Source§

impl HasAlpha<Color> for Color

Source§

fn get_color(&self) -> Self

Retrieve the color component
Source§

fn set_color(&mut self, color: Self) -> &Self

Set the color component
Source§

fn split(&self) -> (Self, f32)

Retrieve the color and aplha components
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 Round for Color

Source§

fn round(self) -> Self

Create color with rounded values
Source§

impl SetAlpha<Color> for Color

Source§

fn set_alpha(&mut self, alpha: f32) -> &Self

Set the alpha component
Source§

fn set_opacity(&mut self, opacity: f32) -> &Self

Set the alpha component as opacity
Source§

fn set_transparency(&mut self, transparency: f32) -> &Self

Set the alpha component as transparency
Source§

impl ColorTransition for Color

Source§

impl Copy for Color

Source§

impl NonRadialSpace for Color

Source§

impl NonSaturationSpace 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<C> AdjustHue for C
where C: Clone + GetHue + SetHue,

Source§

fn adjust_hue(self, delta: f32) -> C

Adjust hue component of color with delta
Source§

fn complement(self) -> Self

Rotate hue component with 180 degrees
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<Fr, To> FromColor<Fr> for To
where To: From<Color>, Fr: Into<Color>,

Source§

fn from_color(from_color: Fr) -> To

Convert from color
Source§

impl<C> GetHue for C
where C: NonRadialSpace,

Source§

fn get_hue(self) -> f32

Retrieve hue component
Source§

impl<C> GetRadialSaturation for C

Source§

fn get_hsl_saturation(self) -> f32

Retrieve hsl saturation
Source§

fn get_hsv_saturation(self) -> f32

Set hsv saturation
Source§

impl<C> Grayscale for C
where C: Saturate,

Source§

fn grayscale(self) -> Self

Desaturate the color to grayscale
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<Fr, To> IntoColor<To> for Fr
where To: FromColor<Fr>,

Source§

fn into_color(self) -> To

Convert into color
Source§

impl<C> Invert for C
where C: ColorTransition,

Source§

fn invert(self) -> C

Invert color
Source§

impl<C> Lighten for C

Source§

fn lighten(self, delta: f32) -> C

Lighten the color with delta
Source§

fn darken(self, delta: f32) -> Self

Darken the color with delta
Source§

impl<C> Saturate for C

Source§

fn saturate(self, delta: f32) -> C

Saturate the color with delta
Source§

fn desaturate(self, delta: f32) -> Self

Desaturate the color with delta
Source§

impl<C> SetHue for C
where C: NonRadialSpace,

Source§

fn set_hue(&mut self, hue: f32) -> C

Set the hue component
Source§

impl<C> SetRadialSaturation for C

Source§

fn set_hsl_saturation(&mut self, saturation: f32) -> C

Retrieve hsl saturation
Source§

fn set_hsv_saturation(&mut self, saturation: f32) -> C

Set hsv saturation
Source§

impl<C> ToHexString for C
where C: Into<RgbColor> + Clone,

Source§

fn to_hex_string(&self) -> String

Represents a color as a hexadecimal string
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<C> Adjust for C