pub struct Color(/* private fields */);Expand description
A color represented by four floating point values.
Implementations§
source§impl Color
impl Color
sourcepub const fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Self
pub const fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Self
Create a new color with the given red, green, blue, and alpha values.
§Parameters
red- The red value.green- The green value.blue- The blue value.alpha- The alpha value.
sourcepub fn from_rgba32(rgba: u32) -> Self
pub fn from_rgba32(rgba: u32) -> Self
sourcepub fn from_rgba64(rgba: u64) -> Self
pub fn from_rgba64(rgba: u64) -> Self
sourcepub fn from_argb32(argb: u32) -> Self
pub fn from_argb32(argb: u32) -> Self
sourcepub fn from_argb64(argb: u64) -> Self
pub fn from_argb64(argb: u64) -> Self
sourcepub const fn new_opaque(red: f32, green: f32, blue: f32) -> Self
pub const fn new_opaque(red: f32, green: f32, blue: f32) -> Self
Create a new color with the given red, green, and blue values.
The alpha value will be set to 1.0.
§Parameters
red- The red value.green- The green value.blue- The blue value.
source§impl Color
impl Color
sourcepub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
Checks whether this color is opaque.
This only returns true if the value is fully solid (e.g. alpha is 1.0).
sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Checks whether this color is transparent.
This only returns true if the value is fully transparent (e.g. alpha is 0.0).
pub fn r_mut(&mut self) -> &mut f32
pub fn g_mut(&mut self) -> &mut f32
pub fn b_mut(&mut self) -> &mut f32
pub fn a_mut(&mut self) -> &mut f32
sourcepub const fn rgb(&self) -> &Vec3
pub const fn rgb(&self) -> &Vec3
Gets the red, green, and blue components of this color as a Vec3.
sourcepub const fn gba(&self) -> &Vec3
pub const fn gba(&self) -> &Vec3
Gets the green, blue, and alpha components of this color as a Vec3.
sourcepub fn rg_mut(&mut self) -> &mut Vec2
pub fn rg_mut(&mut self) -> &mut Vec2
Gets a mutable reference to the red and green components of this color as
a Vec2.
sourcepub fn gb_mut(&mut self) -> &mut Vec2
pub fn gb_mut(&mut self) -> &mut Vec2
Gets a mutable reference to the green and blue components of this color as
a Vec2.
sourcepub fn ba_mut(&mut self) -> &mut Vec2
pub fn ba_mut(&mut self) -> &mut Vec2
Gets a mutable reference to the blue and alpha components of this color as
a Vec2.
sourcepub fn rgb_mut(&mut self) -> &mut Vec3
pub fn rgb_mut(&mut self) -> &mut Vec3
Gets a mutable reference to the red, green, and blue components of this
color as a Vec3.
sourcepub fn gba_mut(&mut self) -> &mut Vec3
pub fn gba_mut(&mut self) -> &mut Vec3
Gets a mutable reference to the green, blue, and alpha components of this
color as a Vec3.
sourcepub fn blend(&self, other: &Self) -> Self
pub fn blend(&self, other: &Self) -> Self
Blends this color with another color, returning the blended result.
Blending makes heavy use of the alpha channel to determine how two colors should be combined. The alpha channel of the other color is used to determine how much of the other color should be blended with this color.
If the alpha cannel of the other color is 1.0, then the other color will be fully blended with this color. If the alpha channel of the other color is 0.0, then the other color will not be blended with this color at all.
§Parameters
other- The other color to blend with.
source§impl Color
impl Color
sourcepub fn set_gb(&mut self, value: &Vec2)
pub fn set_gb(&mut self, value: &Vec2)
Sets the green and blue components of this color.
§Parameters
value- The new green and blue values.
sourcepub fn set_ba(&mut self, value: &Vec2)
pub fn set_ba(&mut self, value: &Vec2)
Sets the blue and alpha components of this color.
§Parameters
value- The new blue and alpha values.
Trait Implementations§
source§impl BorrowMut<Vec4> for Color
impl BorrowMut<Vec4> for Color
source§fn borrow_mut(&mut self) -> &mut Vec4
fn borrow_mut(&mut self) -> &mut Vec4
source§impl PartialOrd for Color
impl PartialOrd for Color
impl Copy for Color
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<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)