pub struct Color {
    pub red: f32,
    pub green: f32,
    pub blue: f32,
    pub alpha: f32,
}
Expand description

An Srgba color.

Fields

red: f32

The red channel. Valid values are from 0.0 to 1.0 inclusive.

green: f32

The green channel. Valid values are from 0.0 to 1.0 inclusive.

blue: f32

The blue channel. Valid values are from 0.0 to 1.0 inclusive.

alpha: f32

The alpha channel. Valid values are from 0.0 to 1.0 inclusive, where 1.0 is fully opaque.

Implementations

Creates a new color with SRGBA components red, green, blue, and alpha ranging from 0.0-1.0.

Creates a new color with SRGBA components red, green, blue, and alpha ranging from 0-255.

Formats the color for CSS.

Returns a gray color with lightness in the red, green, and blue channels and an alpha of 1.0.

Returns a new color with the same red, green, and blue values, but replacing the current alpha with the parameter.

Returns this color after lightening it by factor. Uses the Laba colorspace for luminance calcluations.

Returns this color after darkening it by factor. Uses the Laba colorspace for luminance calcluations.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

Equivalent to the CSS color keywords of the same name.

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

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

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

Convert the source color to the destination color using the specified method Read more

Convert the source color to the destination color using the bradford method by default Read more

Gets the TypeId of self. Read more

Returns the underlying type as Any.

Returns the underlying type as Any.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Convert into T with values clamped to the color defined bounds Read more

Convert into T. The resulting color might be invalid in its color space Read more

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

Converts the given value to a String. 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.

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more