Struct xcell_errors::for_3rd::Color
source · Expand description
The color
Fields§
§r: f64Red
g: f64Green
b: f64Blue
a: f64Alpha
Implementations§
source§impl Color
impl Color
sourcepub const fn new(r: f64, g: f64, b: f64, a: f64) -> Color
pub const fn new(r: f64, g: f64, b: f64, a: f64) -> Color
Arguments:
r: Red value [0..1]g: Green value [0..1]b: Blue value [0..1]a: Alpha value [0..1]
pub fn to_array(&self) -> [f64; 4]
pub fn to_rgba8(&self) -> [u8; 4]
pub fn to_rgba16(&self) -> [u16; 4]
pub fn clamp(&self) -> Color
sourcepub fn from_rgb(r: f64, g: f64, b: f64) -> Color
👎Deprecated: Use new instead.
pub fn from_rgb(r: f64, g: f64, b: f64) -> Color
Arguments:
r: Red value [0..1]g: Green value [0..1]b: Blue value [0..1]
sourcepub fn from_rgba(r: f64, g: f64, b: f64, a: f64) -> Color
👎Deprecated: Use new instead.
pub fn from_rgba(r: f64, g: f64, b: f64, a: f64) -> Color
Arguments:
r: Red value [0..1]g: Green value [0..1]b: Blue value [0..1]a: Alpha value [0..1]
sourcepub fn from_rgb_u8(r: u8, g: u8, b: u8) -> Color
👎Deprecated: Use from_rgba8 instead.
pub fn from_rgb_u8(r: u8, g: u8, b: u8) -> Color
Arguments:
r: Red value [0..255]g: Green value [0..255]b: Blue value [0..255]
sourcepub fn from_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color
👎Deprecated: Use from_rgba8 instead.
pub fn from_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color
Arguments:
r: Red value [0..255]g: Green value [0..255]b: Blue value [0..255]a: Alpha value [0..255]
sourcepub fn from_rgba8(r: u8, g: u8, b: u8, a: u8) -> Color
pub fn from_rgba8(r: u8, g: u8, b: u8, a: u8) -> Color
Arguments:
r: Red value [0..255]g: Green value [0..255]b: Blue value [0..255]a: Alpha value [0..255]
sourcepub fn from_linear_rgb(r: f64, g: f64, b: f64) -> Color
👎Deprecated: Use from_linear_rgba instead.
pub fn from_linear_rgb(r: f64, g: f64, b: f64) -> Color
Arguments:
r: Red value [0..1]g: Green value [0..1]b: Blue value [0..1]
sourcepub fn from_linear_rgba(r: f64, g: f64, b: f64, a: f64) -> Color
pub fn from_linear_rgba(r: f64, g: f64, b: f64, a: f64) -> Color
Arguments:
r: Red value [0..1]g: Green value [0..1]b: Blue value [0..1]a: Alpha value [0..1]
sourcepub fn from_linear_rgb_u8(r: u8, g: u8, b: u8) -> Color
👎Deprecated: Use from_linear_rgba8 instead.
pub fn from_linear_rgb_u8(r: u8, g: u8, b: u8) -> Color
Arguments:
r: Red value [0..255]g: Green value [0..255]b: Blue value [0..255]
sourcepub fn from_linear_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color
👎Deprecated: Use from_linear_rgba8 instead.
pub fn from_linear_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color
Arguments:
r: Red value [0..255]g: Green value [0..255]b: Blue value [0..255]a: Alpha value [0..255]
sourcepub fn from_linear_rgba8(r: u8, g: u8, b: u8, a: u8) -> Color
pub fn from_linear_rgba8(r: u8, g: u8, b: u8, a: u8) -> Color
Arguments:
r: Red value [0..255]g: Green value [0..255]b: Blue value [0..255]a: Alpha value [0..255]
sourcepub fn from_hsv(h: f64, s: f64, v: f64) -> Color
👎Deprecated: Use from_hsva instead.
pub fn from_hsv(h: f64, s: f64, v: f64) -> Color
Arguments:
h: Hue angle [0..360]s: Saturation [0..1]v: Value [0..1]
sourcepub fn from_hsva(h: f64, s: f64, v: f64, a: f64) -> Color
pub fn from_hsva(h: f64, s: f64, v: f64, a: f64) -> Color
Arguments:
h: Hue angle [0..360]s: Saturation [0..1]v: Value [0..1]a: Alpha [0..1]
sourcepub fn from_hsl(h: f64, s: f64, l: f64) -> Color
👎Deprecated: Use from_hsla instead.
pub fn from_hsl(h: f64, s: f64, l: f64) -> Color
Arguments:
h: Hue angle [0..360]s: Saturation [0..1]l: Lightness [0..1]
sourcepub fn from_hsla(h: f64, s: f64, l: f64, a: f64) -> Color
pub fn from_hsla(h: f64, s: f64, l: f64, a: f64) -> Color
Arguments:
h: Hue angle [0..360]s: Saturation [0..1]l: Lightness [0..1]a: Alpha [0..1]
sourcepub fn from_hwb(h: f64, w: f64, b: f64) -> Color
👎Deprecated: Use from_hwba instead.
pub fn from_hwb(h: f64, w: f64, b: f64) -> Color
Arguments:
h: Hue angle [0..360]w: Whiteness [0..1]b: Blackness [0..1]
sourcepub fn from_hwba(h: f64, w: f64, b: f64, a: f64) -> Color
pub fn from_hwba(h: f64, w: f64, b: f64, a: f64) -> Color
Arguments:
h: Hue angle [0..360]w: Whiteness [0..1]b: Blackness [0..1]a: Alpha [0..1]
sourcepub fn from_oklab(l: f64, a: f64, b: f64) -> Color
👎Deprecated: Use from_oklaba instead.
pub fn from_oklab(l: f64, a: f64, b: f64) -> Color
Arguments:
l: Perceived lightnessa: How green/red the color isb: How blue/yellow the color is
sourcepub fn from_oklaba(l: f64, a: f64, b: f64, alpha: f64) -> Color
pub fn from_oklaba(l: f64, a: f64, b: f64, alpha: f64) -> Color
Arguments:
l: Perceived lightnessa: How green/red the color isb: How blue/yellow the color isalpha: Alpha [0..1]
sourcepub fn from_html<S>(s: S) -> Result<Color, ParseColorError>where
S: AsRef<str>,
pub fn from_html<S>(s: S) -> Result<Color, ParseColorError>where
S: AsRef<str>,
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)");pub fn name(&self) -> Option<&'static str>
sourcepub fn rgba(&self) -> (f64, f64, f64, f64)
👎Deprecated
pub fn rgba(&self) -> (f64, f64, f64, f64)
Returns: (r, g, b, a)
- Red, green, blue and alpha in the range [0..1]
sourcepub fn rgba_u8(&self) -> (u8, u8, u8, u8)
👎Deprecated: Use to_rgba8 instead.
pub fn rgba_u8(&self) -> (u8, u8, u8, u8)
Returns: (r, g, b, a)
- Red, green, blue and alpha in the range [0..255]
sourcepub fn to_hsva(&self) -> (f64, f64, f64, f64)
pub fn to_hsva(&self) -> (f64, f64, f64, f64)
Returns: (h, s, v, a)
h: Hue angle [0..360]s: Saturation [0..1]v: Value [0..1]a: Alpha [0..1]
sourcepub fn to_hsla(&self) -> (f64, f64, f64, f64)
pub fn to_hsla(&self) -> (f64, f64, f64, f64)
Returns: (h, s, l, a)
h: Hue angle [0..360]s: Saturation [0..1]l: Lightness [0..1]a: Alpha [0..1]
sourcepub fn to_hwba(&self) -> (f64, f64, f64, f64)
pub fn to_hwba(&self) -> (f64, f64, f64, f64)
Returns: (h, w, b, a)
h: Hue angle [0..360]w: Whiteness [0..1]b: Blackness [0..1]a: Alpha [0..1]
sourcepub fn to_linear_rgba(&self) -> (f64, f64, f64, f64)
pub fn to_linear_rgba(&self) -> (f64, f64, f64, f64)
Returns: (r, g, b, a)
- Red, green, blue and alpha in the range [0..1]
sourcepub fn to_linear_rgba_u8(&self) -> (u8, u8, u8, u8)
pub fn to_linear_rgba_u8(&self) -> (u8, u8, u8, u8)
Returns: (r, g, b, a)
- Red, green, blue and alpha in the range [0..255]
sourcepub fn to_hex_string(&self) -> String
pub fn to_hex_string(&self) -> String
Get the RGB hexadecimal color string.
sourcepub fn to_rgb_string(&self) -> String
pub fn to_rgb_string(&self) -> String
Get the CSS rgb() format string.
sourcepub fn interpolate_rgb(&self, other: &Color, t: f64) -> Color
pub fn interpolate_rgb(&self, other: &Color, t: f64) -> Color
Blend this color with the other one, in the RGB color-space. t in the range [0..1].
sourcepub fn interpolate_linear_rgb(&self, other: &Color, t: f64) -> Color
pub fn interpolate_linear_rgb(&self, other: &Color, t: f64) -> Color
Blend this color with the other one, in the linear RGB color-space. t in the range [0..1].
sourcepub fn interpolate_hsv(&self, other: &Color, t: f64) -> Color
pub fn interpolate_hsv(&self, other: &Color, t: f64) -> Color
Blend this color with the other one, in the HSV color-space. t in the range [0..1].
Trait Implementations§
source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
Implement Serde deserialization from string
source§fn deserialize<D>(
deserializer: D
) -> Result<Color, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Color, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl PartialOrd<Color> for Color
impl PartialOrd<Color> for Color
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl Serialize for Color
impl Serialize for Color
Implement Serde serialization into HEX string