pub struct Rgb {
pub r: u8,
pub g: u8,
pub b: u8,
}Fields§
§r: u8§g: u8§b: u8Implementations§
Source§impl Rgb
impl Rgb
pub const fn as_floats(self) -> (f64, f64, f64)
Sourcepub const fn to_array(self) -> [f32; 3]
pub const fn to_array(self) -> [f32; 3]
Returns [r, g, b] as f32 values in 0.0-1.0 range.
Useful for GPU APIs like wgpu that expect f32 colors.
Sourcepub const fn to_array_with_alpha(self) -> [f32; 4]
pub const fn to_array_with_alpha(self) -> [f32; 4]
Returns [r, g, b, a] as f32 values with alpha = 1.0.
Useful for GPU APIs like wgpu that expect f32 RGBA colors.
pub fn to_array_string(self) -> String
Sourcepub fn lighten(self, factor: f64) -> Self
pub fn lighten(self, factor: f64) -> Self
Lighten the color by increasing lightness in HSL space.
factor of 0.0 returns the original color, 1.0 returns white.
The lightness is increased proportionally to the remaining headroom.
Sourcepub fn darken(self, factor: f64) -> Self
pub fn darken(self, factor: f64) -> Self
Darken the color by decreasing lightness in HSL space.
factor of 0.0 returns the original color, 1.0 returns black.
The lightness is decreased proportionally to the current lightness.
Trait Implementations§
impl Copy for Rgb
impl Eq for Rgb
impl StructuralPartialEq for Rgb
Auto Trait Implementations§
impl Freeze for Rgb
impl RefUnwindSafe for Rgb
impl Send for Rgb
impl Sync for Rgb
impl Unpin for Rgb
impl UnwindSafe for Rgb
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
Mutably borrows from an owned value. Read more