pub struct Color {
    pub r: f64,
    pub g: f64,
    pub b: f64,
    pub a: f64,
}
Expand description

The color

Fields

r: f64

Red

g: f64

Green

b: f64

Blue

a: f64

Alpha

Implementations

Arguments:

  • r: Red value [0..1]
  • g: Green value [0..1]
  • b: Blue value [0..1]
  • a: Alpha value [0..1]
👎 Deprecated:

Use new instead.

Arguments:

  • r: Red value [0..1]
  • g: Green value [0..1]
  • b: Blue value [0..1]
👎 Deprecated:

Use new instead.

Arguments:

  • r: Red value [0..1]
  • g: Green value [0..1]
  • b: Blue value [0..1]
  • a: Alpha value [0..1]
👎 Deprecated:

Use from_rgba8 instead.

Arguments:

  • r: Red value [0..255]
  • g: Green value [0..255]
  • b: Blue value [0..255]
👎 Deprecated:

Use from_rgba8 instead.

Arguments:

  • r: Red value [0..255]
  • g: Green value [0..255]
  • b: Blue value [0..255]
  • a: Alpha value [0..255]

Arguments:

  • r: Red value [0..255]
  • g: Green value [0..255]
  • b: Blue value [0..255]
  • a: Alpha value [0..255]
👎 Deprecated:

Use from_linear_rgba instead.

Arguments:

  • r: Red value [0..1]
  • g: Green value [0..1]
  • b: Blue value [0..1]

Arguments:

  • r: Red value [0..1]
  • g: Green value [0..1]
  • b: Blue value [0..1]
  • a: Alpha value [0..1]
👎 Deprecated:

Use from_linear_rgba8 instead.

Arguments:

  • r: Red value [0..255]
  • g: Green value [0..255]
  • b: Blue value [0..255]
👎 Deprecated:

Use from_linear_rgba8 instead.

Arguments:

  • r: Red value [0..255]
  • g: Green value [0..255]
  • b: Blue value [0..255]
  • a: Alpha value [0..255]

Arguments:

  • r: Red value [0..255]
  • g: Green value [0..255]
  • b: Blue value [0..255]
  • a: Alpha value [0..255]
👎 Deprecated:

Use from_hsva instead.

Arguments:

  • h: Hue angle [0..360]
  • s: Saturation [0..1]
  • v: Value [0..1]

Arguments:

  • h: Hue angle [0..360]
  • s: Saturation [0..1]
  • v: Value [0..1]
  • a: Alpha [0..1]
👎 Deprecated:

Use from_hsla instead.

Arguments:

  • h: Hue angle [0..360]
  • s: Saturation [0..1]
  • l: Lightness [0..1]

Arguments:

  • h: Hue angle [0..360]
  • s: Saturation [0..1]
  • l: Lightness [0..1]
  • a: Alpha [0..1]
👎 Deprecated:

Use from_hwba instead.

Arguments:

  • h: Hue angle [0..360]
  • w: Whiteness [0..1]
  • b: Blackness [0..1]

Arguments:

  • h: Hue angle [0..360]
  • w: Whiteness [0..1]
  • b: Blackness [0..1]
  • a: Alpha [0..1]
👎 Deprecated:

Use from_oklaba instead.

Arguments:

  • l: Perceived lightness
  • a: How green/red the color is
  • b: How blue/yellow the color is

Arguments:

  • l: Perceived lightness
  • a: How green/red the color is
  • b: How blue/yellow the color is
  • alpha: Alpha [0..1]

Arguments:

  • l: Lightness
  • a: Distance along the a axis
  • b: Distance along the b axis
  • alpha: Alpha [0..1]

Returns: (l, a, b, alpha)

Blend this color with the other one, in the Lab color-space. t in the range [0..1].

Arguments:

  • l: Lightness
  • c: Chroma
  • h: Hue angle in radians
  • alpha: Alpha [0..1]

Returns: (l, c, h, alpha)

Blend this color with the other one, in the LCH color-space. t in the range [0..1].

Create color from CSS color string.

Examples
use csscolorparser::Color;

let c = Color::from_html("rgb(255,0,0)")?;

assert_eq!(c.to_array(), [1.0, 0.0, 0.0, 1.0]);
assert_eq!(c.to_rgba8(), [255, 0, 0, 255]);
assert_eq!(c.to_hex_string(), "#ff0000");
assert_eq!(c.to_rgb_string(), "rgb(255,0,0)");
👎 Deprecated

Returns: (r, g, b, a)

  • Red, green, blue and alpha in the range [0..1]
👎 Deprecated:

Use to_rgba8 instead.

Returns: (r, g, b, a)

  • Red, green, blue and alpha in the range [0..255]

Returns: (h, s, v, a)

  • h: Hue angle [0..360]
  • s: Saturation [0..1]
  • v: Value [0..1]
  • a: Alpha [0..1]

Returns: (h, s, l, a)

  • h: Hue angle [0..360]
  • s: Saturation [0..1]
  • l: Lightness [0..1]
  • a: Alpha [0..1]

Returns: (h, w, b, a)

  • h: Hue angle [0..360]
  • w: Whiteness [0..1]
  • b: Blackness [0..1]
  • a: Alpha [0..1]

Returns: (r, g, b, a)

  • Red, green, blue and alpha in the range [0..1]

Returns: (r, g, b, a)

  • Red, green, blue and alpha in the range [0..255]

Returns: (l, a, b, alpha)

Get the RGB hexadecimal color string.

Get the CSS rgb() format string.

Blend this color with the other one, in the RGB color-space. t in the range [0..1].

Blend this color with the other one, in the linear RGB color-space. t in the range [0..1].

Blend this color with the other one, in the HSV color-space. t in the range [0..1].

Blend this color with the other one, in the Oklab color-space. t in the range [0..1].

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Formats the value using the given formatter. Read more

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

Implement Serde deserialization from string

Deserialize this value from the given Serde deserializer. 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.

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.

Convert rust-rgb’s RGB<f64> type into Color.

Converts to this type from the input type.

Convert rust-rgb’s RGBA<f64> type into Color.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Implement Serde serialization into HEX string

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

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

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.