[][src]Struct bracket_color::prelude::RGBA

pub struct RGBA {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}

Represents an R/G/B triplet, in the range 0..1 (32-bit float)

Fields

r: f32g: f32b: f32a: f32

Methods

impl RGBA[src]

#[must_use]pub fn new() -> Self[src]

Constructs a new, zeroed (black) RGB triplet.

#[must_use]pub fn from_f32(r: f32, g: f32, b: f32, a: f32) -> Self[src]

Constructs a new RGB color, from 3 32-bit floats in the range 0..1

#[must_use]pub fn from_u8(r: u8, g: u8, b: u8, a: u8) -> Self[src]

Constructs a new RGB color, from 3 bytes in the range 0..255

#[must_use]pub fn named(col: (u8, u8, u8)) -> Self[src]

Construct an RGB color from a tuple of u8, or a named constant

pub fn from_hex<S: AsRef<str>>(
    code: S
) -> Result<Self, HtmlColorConversionError>
[src]

Constructs from an HTML color code (e.g. "#eeffeeff")

Errors

#[must_use]pub fn to_rgb(&self) -> RGB[src]

Converts to an RGB, dropping the alpha component

#[must_use]pub fn to_greyscale(&self) -> Self[src]

Applies a quick grayscale conversion to the color

#[must_use]pub fn desaturate(&self) -> Self[src]

Applies a lengthier desaturate (via HSV) to the color

#[must_use]pub fn lerp(&self, color: Self, percent: f32) -> Self[src]

Lerps by a specified percentage (from 0 to 1) between this color and another

#[must_use]pub fn lerp_alpha(&self, color: Self, percent: f32) -> Self[src]

Lerps only the alpha channel, by a specified percentage (from 0 to 1) between this color and another

Trait Implementations

impl Add<RGBA> for RGBA[src]

Support adding an RGB to a color. The result is clamped via the constructor.

type Output = Self

The resulting type after applying the + operator.

impl Add<f32> for RGBA[src]

Support adding a float to a color. The result is clamped via the constructor.

type Output = Self

The resulting type after applying the + operator.

impl Clone for RGBA[src]

impl Copy for RGBA[src]

impl Debug for RGBA[src]

impl Default for RGBA[src]

impl From<(u8, u8, u8, u8)> for RGBA[src]

Support conversion from a color tuple

impl From<(u8, u8, u8)> for RGBA[src]

Support conversion from a color tuple

impl From<HSV> for RGBA[src]

Support conversion from HSV

impl From<RGB> for RGBA[src]

Support conversion from RGB

impl From<RGBA> for HSV[src]

Support conversion from RGBA

impl From<RGBA> for RGB[src]

Support conversion from RGBA

impl Mul<RGBA> for RGBA[src]

Support multiplying a color by another color. The result is clamped via the constructor.

type Output = Self

The resulting type after applying the * operator.

impl Mul<f32> for RGBA[src]

Support multiplying a color by a float. The result is clamped via the constructor.

type Output = Self

The resulting type after applying the * operator.

impl PartialEq<RGBA> for RGBA[src]

impl StructuralPartialEq for RGBA[src]

impl Sub<RGBA> for RGBA[src]

Support subtracting an RGB from a color. The result is clamped via the constructor.

type Output = Self

The resulting type after applying the - operator.

impl Sub<f32> for RGBA[src]

Support subtracting a float from a color. The result is clamped via the constructor.

type Output = Self

The resulting type after applying the - operator.

Auto Trait Implementations

impl RefUnwindSafe for RGBA

impl Send for RGBA

impl Sync for RGBA

impl Unpin for RGBA

impl UnwindSafe for RGBA

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.