Struct bracket_color::rgb::RGB
source · [−]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
sourceimpl RGB
impl RGB
sourcepub fn from_u8(r: u8, g: u8, b: u8) -> Self
pub fn from_u8(r: u8, g: u8, b: u8) -> Self
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 to_greyscale(&self) -> Self
pub fn to_greyscale(&self) -> Self
Applies a quick grayscale conversion to the color
sourcepub fn desaturate(&self) -> Self
pub fn desaturate(&self) -> Self
Applies a lengthier desaturate (via HSV) to the color
Trait Implementations
sourceimpl Add<RGB> for RGB
impl Add<RGB> for RGB
Support adding an RGB to a color. The result is clamped via the constructor.
sourceimpl Add<f32> for RGB
impl Add<f32> for RGB
Support adding a float to a color. The result is clamped via the constructor.
sourceimpl Mul<RGB> for RGB
impl Mul<RGB> for RGB
Support multiplying a color by another color. The result is clamped via the constructor.
sourceimpl Mul<f32> for RGB
impl Mul<f32> for RGB
Support multiplying a color by a float. The result is clamped via the constructor.
sourceimpl Sub<RGB> for RGB
impl Sub<RGB> for RGB
Support subtracting an RGB from a color. The result is clamped via the constructor.
sourceimpl Sub<f32> for RGB
impl Sub<f32> for RGB
Support subtracting a float from a color. The result is clamped via the constructor.