orbtk_utils

Struct Color

Source
#[repr(packed(1))]
pub struct Color { pub data: u32, }
Expand description

A r g b a color.

Fields§

§data: u32

Implementations§

Source§

impl Color

Source

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

Create a new color from RGB

Source

pub fn hsv(h: f64, s: f64, v: f64) -> Self

Create a new color from HSV(0.0-360.0, 0.0-1.0, 0.0-1.0)

Source

pub fn hsl(h: f64, s: f64, l: f64) -> Self

Create a new color from HSL(0.0-360.0, 0.0-1.0, 0.0-1.0)

Source

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

Create a new color from RGB and alpha values

Source

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

Create a new color from HSV(0.0-360.0, 0.0-1.0, 0.0-1.0) and alpha values(0.0-1.0)

Source

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

Create a new color from HSL(0.0-360.0, 0.0-1.0, 0.0-1.0) and alpha values(0.0-1.0)

Source

pub fn r(self) -> u8

Get the r value

Source

pub fn g(self) -> u8

Get the g value

Source

pub fn b(self) -> u8

Get the b value

Source

pub fn a(self) -> u8

Get the alpha value

Source

pub fn from_name(name: &str) -> Option<Color>

Attempts to get a color from its name, all the CSS colors are avaible and some other ones also.

Source

pub fn interpolate(start_color: Color, end_color: Color, scale: f64) -> Color

Interpolate between two colors

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a copy 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<(), Error>

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

impl Default for Color

Source§

fn default() -> Color

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

impl From<&str> for Color

Source§

fn from(s: &str) -> Color

Converts to this type from the input type.
Source§

impl From<Brush> for Color

Source§

fn from(b: Brush) -> Color

Converts to this type from the input type.
Source§

impl From<Color> for Brush

Source§

fn from(c: Color) -> Brush

Converts to this type from the input type.
Source§

impl From<Color> for GradientStop

Source§

fn from(color: Color) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Color

Source§

fn from(s: String) -> Color

Converts to this type from the input type.
Source§

impl PartialEq for Color

Compares two colors (the alpha value is ignored)

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

Source§

fn partial_cmp(&self, other: &Color) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToString for Color

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl Copy 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.