pub struct RGB {
pub r: f32,
pub g: f32,
pub b: f32,
}
Expand description
Represents an R/G/B triplet, in the range 0..1 (32-bit float)
Fields§
§r: f32
The red component (0..1)
g: f32
The green components (0..1)
b: f32
The blue component (0..1)
Implementations§
Source§impl RGB
impl RGB
Sourcepub fn from_u8(r: u8, g: u8, b: u8) -> RGB
pub fn from_u8(r: u8, g: u8, b: u8) -> RGB
Constructs a new RGB color, from 3 bytes in the range 0..255
§Arguments
r
- the red component, ranged from 0 to 255g
- the green component, ranged from 0 to 255b
- the blue component, ranged from 0 to 255
§Example
use bracket_color::prelude::*;
let red = RGB::from_u8(255, 0, 0);
let green = RGB::from_u8(0, 255, 0);
Sourcepub fn from_hex<S>(code: S) -> Result<RGB, HtmlColorConversionError>
pub fn from_hex<S>(code: S) -> Result<RGB, HtmlColorConversionError>
Sourcepub fn to_greyscale(&self) -> RGB
pub fn to_greyscale(&self) -> RGB
Applies a quick grayscale conversion to the color
Sourcepub fn desaturate(&self) -> RGB
pub fn desaturate(&self) -> RGB
Applies a lengthier desaturate (via HSV) to the color
Trait Implementations§
Source§impl Add<f32> for RGB
Support adding a float to a color. The result is clamped via the constructor.
impl Add<f32> for RGB
Support adding a float to a color. The result is clamped via the constructor.
Source§impl Mul<f32> for RGB
Support multiplying a color by a float. The result is clamped via the constructor.
impl Mul<f32> for RGB
Support multiplying a color by a float. The result is clamped via the constructor.
Source§impl Mul for RGB
Support multiplying a color by another color. The result is clamped via the constructor.
impl Mul for RGB
Support multiplying a color by another color. The result is clamped via the constructor.
Source§impl Sub<f32> for RGB
Support subtracting a float from a color. The result is clamped via the constructor.
impl Sub<f32> for RGB
Support subtracting a float from a color. The result is clamped via the constructor.
Source§impl Sub for RGB
Support subtracting an RGB from a color. The result is clamped via the constructor.
impl Sub for RGB
Support subtracting an RGB from a color. The result is clamped via the constructor.
impl Copy 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