Struct coloriz::color::rgb::RGB[][src]

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

RGB color

Fields

r: u8

Red

g: u8

Green

b: u8

Blue

Implementations

impl RGB[src]

pub const fn new(r: u8, g: u8, b: u8) -> Self[src]

Creates a new RGB color

pub const fn from_hex(hex: u32) -> Self[src]

Creates a new RGB color with a hex code

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

Creates a new RGB color with three f32 values

pub const fn gray(x: u8) -> Self[src]

Creates a grayscale RGB color

pub fn gray_f32(x: f32) -> Self[src]

Creates a grayscale RGB color with a f32 value

pub fn from_hsl(hsl: HSL) -> Self[src]

Creates a new RGB color from a HSL color

pub fn lerp(&self, other: Self, t: f32) -> Self[src]

Computes the linear interpolation between self and other for t

Trait Implementations

impl Add<&'_ RGB> for RGB[src]

type Output = RGB

The resulting type after applying the + operator.

fn add(self, rhs: &RGB) -> Self::Output[src]

Performs the + operation. Read more

impl Add<&'_ RGB> for &RGB[src]

type Output = RGB

The resulting type after applying the + operator.

fn add(self, rhs: &RGB) -> Self::Output[src]

Performs the + operation. Read more

impl Add<RGB> for RGB[src]

type Output = RGB

The resulting type after applying the + operator.

fn add(self, rhs: RGB) -> Self::Output[src]

Performs the + operation. Read more

impl Add<RGB> for &RGB[src]

type Output = RGB

The resulting type after applying the + operator.

fn add(self, rhs: RGB) -> Self::Output[src]

Performs the + operation. Read more

impl Clone for RGB[src]

fn clone(&self) -> RGB[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl ColorApply for RGB[src]

fn to<C: ?Sized>(self, c: C) -> StyledText where
    C: Colorize
[src]

Applies self to the foreground color of c Read more

fn under<C: ?Sized>(self, c: C) -> StyledText where
    C: Colorize
[src]

Applies self to the background color of c Read more

impl Debug for RGB[src]

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

Formats the value using the given formatter. Read more

impl From<(f32, f32, f32)> for RGB[src]

fn from((r, g, b): (f32, f32, f32)) -> Self[src]

Performs the conversion.

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

fn from((r, g, b): (u8, u8, u8)) -> Self[src]

Performs the conversion.

impl From<HSL> for RGB[src]

fn from(hsl: HSL) -> Self[src]

Performs the conversion.

impl From<RGB> for HSL[src]

fn from(rgb: RGB) -> Self[src]

Performs the conversion.

impl From<RGB> for Color[src]

fn from(rgb: RGB) -> Self[src]

Performs the conversion.

impl From<RGB> for ColorStyle[src]

fn from(rgb: RGB) -> Self[src]

Performs the conversion.

impl Mul<&'_ f32> for RGB[src]

type Output = RGB

The resulting type after applying the * operator.

fn mul(self, rhs: &f32) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<&'_ f32> for &RGB[src]

type Output = RGB

The resulting type after applying the * operator.

fn mul(self, rhs: &f32) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<f32> for RGB[src]

type Output = RGB

The resulting type after applying the * operator.

fn mul(self, rhs: f32) -> Self::Output[src]

Performs the * operation. Read more

impl Mul<f32> for &RGB[src]

type Output = RGB

The resulting type after applying the * operator.

fn mul(self, rhs: f32) -> Self::Output[src]

Performs the * operation. Read more

impl Neg for RGB[src]

type Output = RGB

The resulting type after applying the - operator.

fn neg(self) -> Self::Output[src]

Performs the unary - operation. Read more

impl Neg for &RGB[src]

type Output = RGB

The resulting type after applying the - operator.

fn neg(self) -> Self::Output[src]

Performs the unary - operation. Read more

impl PartialEq<RGB> for RGB[src]

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

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &RGB) -> bool[src]

This method tests for !=.

impl Sub<&'_ RGB> for RGB[src]

type Output = RGB

The resulting type after applying the - operator.

fn sub(self, rhs: &RGB) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<&'_ RGB> for &RGB[src]

type Output = RGB

The resulting type after applying the - operator.

fn sub(self, rhs: &RGB) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<RGB> for RGB[src]

type Output = RGB

The resulting type after applying the - operator.

fn sub(self, rhs: RGB) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<RGB> for &RGB[src]

type Output = RGB

The resulting type after applying the - operator.

fn sub(self, rhs: RGB) -> Self::Output[src]

Performs the - operation. Read more

impl Copy for RGB[src]

impl Eq for RGB[src]

impl StructuralEq for RGB[src]

impl StructuralPartialEq for RGB[src]

Auto Trait Implementations

impl RefUnwindSafe for RGB

impl Send for RGB

impl Sync for RGB

impl Unpin for RGB

impl UnwindSafe for RGB

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

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.

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

Performs the conversion.

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.

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

Performs the conversion.