pub struct Colour { /* private fields */ }
Implementations
sourceimpl Colour
impl Colour
pub const WHITE: Colour
pub const LIGHT_GREY: Colour
pub const GREY: Colour
pub const DARK_GREY: Colour
pub const BLACK: Colour
pub const ORANGE_RED: Colour
pub const ORANGE: Colour
pub const DARK_RED: Colour
pub const RED: Colour
pub const LIGHT_RED: Colour
pub const DARK_GREEN: Colour
pub const GREEN: Colour
pub const LIGHT_GREEN: Colour
pub const DARK_BLUE: Colour
pub const BLUE: Colour
pub const LIGHT_BLUE: Colour
pub const MAGENTA: Colour
pub const CYAN: Colour
pub const YELLOW: Colour
sourcepub fn from_hex_str(hex: &str) -> Result<Color, ColourParseError>
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
pub fn new_from_f32s(red: f32, green: f32, blue: f32, alpha: f32) -> Self
pub const fn new_from_u32s(red: u32, green: u32, blue: u32, alpha: u32) -> Self
pub const fn new_from_u8s(red: u8, green: u8, blue: u8, alpha: u8) -> Self
pub const fn new_from_rgba(rgba: u32) -> Self
pub fn red_f32(&self) -> f32
pub fn red_u32(&self) -> u32
pub fn red_u8(&self) -> u8
pub fn green_f32(&self) -> f32
pub fn green_u32(&self) -> u32
pub fn green_u8(&self) -> u8
pub fn blue_f32(&self) -> f32
pub fn blue_u32(&self) -> u32
pub fn blue_u8(&self) -> u8
pub fn alpha_f32(&self) -> f32
pub fn alpha_u32(&self) -> u32
pub fn alpha_u8(&self) -> u8
pub fn mix(self, other: Self, amount: f32) -> Self
pub fn mix_no_alpha(self, other: Self, amount: f32) -> Self
pub fn replace_alpha_f32(self, alpha: f32) -> Self
pub fn replace_alpha_u32(self, alpha: u32) -> Self
pub fn set_alpha_f32(&mut self, alpha: f32)
pub fn set_alpha_u32(&mut self, alpha: u32)
pub fn to_rgba_u32(self) -> u32
Trait Implementations
sourceimpl AddAssign<Colour> for Colour
impl AddAssign<Colour> for Colour
sourcefn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the +=
operation. Read more
sourceimpl DivAssign<Colour> for Colour
impl DivAssign<Colour> for Colour
sourcefn div_assign(&mut self, other: Self)
fn div_assign(&mut self, other: Self)
Performs the /=
operation. Read more
sourceimpl DivAssign<f32> for Colour
impl DivAssign<f32> for Colour
sourcefn div_assign(&mut self, val: f32)
fn div_assign(&mut self, val: f32)
Performs the /=
operation. Read more
sourceimpl MulAssign<Colour> for Colour
impl MulAssign<Colour> for Colour
sourcefn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
Performs the *=
operation. Read more
sourceimpl MulAssign<f32> for Colour
impl MulAssign<f32> for Colour
sourcefn mul_assign(&mut self, val: f32)
fn mul_assign(&mut self, val: f32)
Performs the *=
operation. Read more
sourceimpl SubAssign<Colour> for Colour
impl SubAssign<Colour> for Colour
sourcefn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the -=
operation. Read more
impl Copy for Colour
impl StructuralPartialEq for Colour
Auto Trait Implementations
impl RefUnwindSafe for Colour
impl Send for Colour
impl Sync for Colour
impl Unpin for Colour
impl UnwindSafe for Colour
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more