Struct Colour

Source
pub struct Colour { /* private fields */ }

Implementations§

Source§

impl Colour

Source

pub const WHITE: Colour

Source

pub const LIGHT_GREY: Colour

Source

pub const GREY: Colour

Source

pub const DARK_GREY: Colour

Source

pub const BLACK: Colour

Source

pub const ORANGE_RED: Colour

Source

pub const ORANGE: Colour

Source

pub const DARK_RED: Colour

Source

pub const RED: Colour

Source

pub const LIGHT_RED: Colour

Source

pub const DARK_GREEN: Colour

Source

pub const GREEN: Colour

Source

pub const LIGHT_GREEN: Colour

Source

pub const DARK_BLUE: Colour

Source

pub const BLUE: Colour

Source

pub const LIGHT_BLUE: Colour

Source

pub const MAGENTA: Colour

Source

pub const CYAN: Colour

Source

pub const YELLOW: Colour

Source

pub fn from_hex_str(hex: &str) -> Result<Color, ColourParseError>

Parses a string hex code into a Colour. The hex code is expected to be 3 or 6 characters long, using base 16 encoding.

This supports the following RGB formats …

  • 123
  • #123
  • 0x123
  • 112233
  • #112233
  • 0x112233

And the following RGBA formats …

  • 1234
  • #1234
  • 0x1234
  • 11223344
  • #11223344
  • 0x11223344
Source

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

Source

pub const fn new_from_u32s(red: u32, green: u32, blue: u32, alpha: u32) -> Self

Source

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

Source

pub const fn new_from_rgba(rgba: u32) -> Self

Source

pub fn red_f32(&self) -> f32

Source

pub fn red_u32(&self) -> u32

Source

pub fn red_u8(&self) -> u8

Source

pub fn green_f32(&self) -> f32

Source

pub fn green_u32(&self) -> u32

Source

pub fn green_u8(&self) -> u8

Source

pub fn blue_f32(&self) -> f32

Source

pub fn blue_u32(&self) -> u32

Source

pub fn blue_u8(&self) -> u8

Source

pub fn alpha_f32(&self) -> f32

Source

pub fn alpha_u32(&self) -> u32

Source

pub fn alpha_u8(&self) -> u8

Source

pub fn mix(self, other: Self, amount: f32) -> Self

Source

pub fn mix_no_alpha(self, other: Self, amount: f32) -> Self

Source

pub fn replace_alpha_f32(self, alpha: f32) -> Self

Source

pub fn replace_alpha_u32(self, alpha: u32) -> Self

Source

pub fn set_alpha_f32(&mut self, alpha: f32)

Source

pub fn set_alpha_u32(&mut self, alpha: u32)

Source

pub fn to_rgba_u32(self) -> u32

Trait Implementations§

Source§

impl Add for Colour

Source§

type Output = Colour

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
Source§

impl AddAssign for Colour

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl Clone for Colour

Source§

fn clone(&self) -> Colour

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 Colour

Source§

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

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

impl Div<f32> for Colour

Source§

type Output = Colour

The resulting type after applying the / operator.
Source§

fn div(self, val: f32) -> Self

Performs the / operation. Read more
Source§

impl Div for Colour

Source§

type Output = Colour

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<f32> for Colour

Source§

fn div_assign(&mut self, val: f32)

Performs the /= operation. Read more
Source§

impl DivAssign for Colour

Source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
Source§

impl Mul<f32> for Colour

Source§

type Output = Colour

The resulting type after applying the * operator.
Source§

fn mul(self, val: f32) -> Self

Performs the * operation. Read more
Source§

impl Mul for Colour

Source§

type Output = Colour

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Colour

Source§

fn mul_assign(&mut self, val: f32)

Performs the *= operation. Read more
Source§

impl MulAssign for Colour

Source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
Source§

impl PartialEq for Colour

Source§

fn eq(&self, other: &Colour) -> 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 Rem for Colour

Source§

type Output = Colour

The resulting type after applying the % operator.
Source§

fn rem(self, other: Self) -> Self

Performs the % operation. Read more
Source§

impl Sub for Colour

Source§

type Output = Colour

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
Source§

impl SubAssign for Colour

Source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
Source§

impl Copy for Colour

Source§

impl StructuralPartialEq for Colour

Auto Trait Implementations§

§

impl Freeze for Colour

§

impl RefUnwindSafe for Colour

§

impl Send for Colour

§

impl Sync for Colour

§

impl Unpin for Colour

§

impl UnwindSafe for Colour

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, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,