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

RGB color, with u8 components

Fields

r: u8

red

g: u8

green

b: u8

blue

Implementations

Create a new RGB color from its components

Return the nearest ANSI color

This is a slow function as it literally tries all ANSI colors and picks the nearest one.

red part in [0,1]

green part in [0,1]

blue part in [0,1]

Compute the Luma value characterizing the “light” of the color, going from 0 (black) to 1 (white).

Reference: https://en.wikipedia.org/wiki/Luma_(video)

tentatively perceptual distance between the two colors, based on a conversion to HSL

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Convert from a (r,g,b) float tupples with components in [0,1[

Converts to this type from the input type.

Converts to this type from the input type.

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.