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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more