Struct RGB

Source
pub struct RGB {
    pub r: Ratio,
    pub g: Ratio,
    pub b: Ratio,
}
Expand description

A struct to represent how much red, green, and blue should be added to create a color.

Valid values for r, g, and b must be a u8 between 0-255, represented as a Ratio.

For more, see the CSS Color Spec.

Fields§

§r: Ratio§g: Ratio§b: Ratio

Trait Implementations§

Source§

impl Clone for RGB

Source§

fn clone(&self) -> RGB

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Color for RGB

Source§

fn to_hsl(self) -> HSL

The algorithm for converting from rgb to hsl format, which determines the equivalent luminosity, saturation, and hue.

Source§

type Alpha = RGBA

Source§

fn to_css(self) -> String

Converts self to its CSS string format. Read more
Source§

fn to_rgb(self) -> RGB

Converts self into its RGB representation. When converting from a color model that supports an alpha channel (e.g. RGBA), the alpha value will not be preserved. Read more
Source§

fn to_rgba(self) -> RGBA

Converts self into its RGBA representation. When converting from a color model that does not supports an alpha channel (e.g. RGB), it will be treated as fully opaque. Read more
Source§

fn to_hsla(self) -> HSLA

Converts self into its HSLA representation. When converting from a color model that does not supports an alpha channel (e.g. RGB), it will be treated as fully opaque. Read more
Source§

fn saturate(self, amount: Ratio) -> Self

Increases the saturation of self by an absolute amount. Operates on the color within its HSL representation and preserves any existing alpha channel. For more, see Less’ Color Operations. Read more
Source§

fn desaturate(self, amount: Ratio) -> Self

Decreases the saturation of self by an absolute amount. Operates on the color within its HSL representation and preserves any existing alpha channel. For more, see Less’ Color Operations. Read more
Source§

fn lighten(self, amount: Ratio) -> Self

Increases the lightness of self by an absolute amount. Operates on the color within its HSL representation and preserves any existing alpha channel. For more, see Less’ Color Operations. Read more
Source§

fn darken(self, amount: Ratio) -> Self

Decreases the lightness of self by an absolute amount. Operates on the color within its HSL representation and preserves any existing alpha channel. For more, see Less’ Color Operations. Read more
Source§

fn fadein(self, amount: Ratio) -> RGBA

Decreases the transparency (or increase the opacity) of self, making it more opaque. For opqaue colors, converts into the alpha equivalent of self, and then increases the opacity. For more, see Less’ Color Operations. Read more
Source§

fn fadeout(self, amount: Ratio) -> RGBA

Increases the transparency (or decrease the opacity) of self, making it less opaque. For opqaue colors, converts into the alpha equivalent of self, and then decreases the opacity. For more, see Less’ Color Operations. Read more
Source§

fn fade(self, amount: Ratio) -> RGBA

Sets the absolute opacity of self, and returns the alpha equivalent. Can be applied to colors whether they already have an opacity value or not. For more, see Less’ Color Operations. Read more
Source§

fn spin(self, amount: Angle) -> Self

Rotate the hue angle of self in either direction. Returns the appropriate RGB representation of the color once it has been spun. For more, see Less’ Color Operations. Read more
Source§

fn mix<T: Color>(self, other: T, weight: Ratio) -> RGBA

Mixes two colors (self and any other Color) together in variable proportion. Takes opacity into account in the calculations. For more, see Less’ Color Operations. Read more
Source§

fn tint(self, weight: Ratio) -> Self

Mixes self with white in variable proportion. Equivalent to calling mix() with white (rgb(255, 255, 255)). For more, see Less’ Color Operations. Read more
Source§

fn shade(self, weight: Ratio) -> Self

Mixes self with white in variable proportion. Equivalent to calling mix() with black (rgb(0, 0, 0)). For more, see Less’ Color Operations. Read more
Source§

fn greyscale(self) -> Self

Remove all saturation from self in the HSL color space. Equivalent to calling desaturate(0) on a color. For more, see Less’ Color Operations. Read more
Source§

impl Debug for RGB

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for RGB

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RGB

Source§

fn eq(&self, other: &RGB) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RGB

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.