Debian Codegraph @

src/color.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
4
5 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!;
6 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
7 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#;
8
9 #[cfg(not(feature = "std"))]
10 use num_traitsrust-analyzer cargo num-traits 0.2.19 crate/::floatrust-analyzer cargo num-traits 0.2.19 float/::Floatrust-analyzer cargo num-traits 0.2.19 float/Float#;
11
12 #[cfg(feature = "rust-rgb")]
13 use rgbrust-analyzer cargo rgb 0.8.52 crate/::{RGBrust-analyzer cargo rgb 0.8.52 formats/rgb/Rgb#, RGBArust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#};
14
15 #[cfg(feature = "serde")]
16 use serderust-analyzer cargo serde 1.0.228 crate/::{derust-analyzer cargo serde_core 1.0.228 de/::Visitorrust-analyzer cargo serde_core 1.0.228 de/Visitor#, Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#, Deserializerrust-analyzer cargo serde_core 1.0.228 de/Deserializer#, Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#};
17
18 use craterust-analyzer cargo csscolorparser 0.8.3 crate/::labrust-analyzer cargo csscolorparser 0.8.3 lab/::{lab_to_linear_rgbrust-analyzer cargo csscolorparser 0.8.3 lab/lab_to_linear_rgb()., linear_rgb_to_labrust-analyzer cargo csscolorparser 0.8.3 lab/linear_rgb_to_lab().};
19 use craterust-analyzer cargo csscolorparser 0.8.3 crate/::utilsrust-analyzer cargo csscolorparser 0.8.3 utils/::*;
20 use craterust-analyzer cargo csscolorparser 0.8.3 crate/::{parserust-analyzer cargo csscolorparser 0.8.3 parser/parse()., ParseColorErrorrust-analyzer cargo csscolorparser 0.8.3 error/ParseColorError#};
21
22 #[cfg(feature = "named-colors")]
23 use craterust-analyzer cargo csscolorparser 0.8.3 crate/::NAMED_COLORSrust-analyzer cargo csscolorparser 0.8.3 named_colors/NAMED_COLORS.;
24
25 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
26 /// The color
27 pub struct Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
28 /// Red
29 pub rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.: f32,
30 /// Green
31 pub grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.: f32,
32 /// Blue
33 pub brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.: f32,
34 /// Alpha
35 pub arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: f32,
36 }
37
38 impl Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
39 /// Arguments:
40 ///
41 /// * `r`: Red value [0..1]
42 /// * `g`: Green value [0..1]
43 /// * `b`: Blue value [0..1]
44 /// * `a`: Alpha value [0..1]
45 pub const fn newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(r: f32, g: f32, b: f32, a: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
46 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] { rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r., grust-analyzer cargo csscolorparser 0.8.3 color/Color#g., brust-analyzer cargo csscolorparser 0.8.3 color/Color#b., arust-analyzer cargo csscolorparser 0.8.3 color/Color#a. }
47 }
48
49 /// Arguments:
50 ///
51 /// * `r`: Red value [0..255]
52 /// * `g`: Green value [0..255]
53 /// * `b`: Blue value [0..255]
54 /// * `a`: Alpha value [0..255]
55 pub const fn from_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_rgba8().(r: u8, g: u8, b: u8, a: u8) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
56 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
57 rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.: r as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
58 grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.: g as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
59 brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.: b as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
60 arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: a as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
61 }
62 }
63
64 /// Arguments:
65 ///
66 /// * `r`: Red value [0..1]
67 /// * `g`: Green value [0..1]
68 /// * `b`: Blue value [0..1]
69 /// * `a`: Alpha value [0..1]
70 pub fn from_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_linear_rgba().(r: f32, g: f32, b: f32, a: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
71 fn from_linearrust-analyzer cargo csscolorparser 0.8.3 color/from_linear().(x: f32) -> f32 {
72 if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]ge().0.0031308 {
73 return 1.055 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().x.powfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]powf().(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().2.4) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().0.055;
74 }
75 12.92 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().x
76 }
77 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(from_linearrust-analyzer cargo csscolorparser 0.8.3 color/from_linear().(r), from_linearrust-analyzer cargo csscolorparser 0.8.3 color/from_linear().(g), from_linearrust-analyzer cargo csscolorparser 0.8.3 color/from_linear().(b), a)
78 }
79
80 /// Arguments:
81 ///
82 /// * `r`: Red value [0..255]
83 /// * `g`: Green value [0..255]
84 /// * `b`: Blue value [0..255]
85 /// * `a`: Alpha value [0..255]
86 pub fn from_linear_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_linear_rgba8().(r: u8, g: u8, b: u8, a: u8) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
87 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_linear_rgba().(
88 r as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
89 g as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
90 b as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
91 a as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().255.0,
92 )
93 }
94
95 /// Arguments:
96 ///
97 /// * `h`: Hue angle [0..360]
98 /// * `s`: Saturation [0..1]
99 /// * `v`: Value [0..1]
100 /// * `a`: Alpha [0..1]
101 pub const fn from_hsvarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_hsva().(h: f32, s: f32, v: f32, a: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
102 let [r, g, b] = hsv_to_rgbrust-analyzer cargo csscolorparser 0.8.3 utils/hsv_to_rgb().(normalize_anglerust-analyzer cargo csscolorparser 0.8.3 utils/normalize_angle().(h), s.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0), v.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0));
103 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(r, g, b, a)
104 }
105
106 /// Arguments:
107 ///
108 /// * `h`: Hue angle [0..360]
109 /// * `s`: Saturation [0..1]
110 /// * `l`: Lightness [0..1]
111 /// * `a`: Alpha [0..1]
112 pub const fn from_hslarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_hsla().(h: f32, s: f32, l: f32, a: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
113 let [r, g, b] = hsl_to_rgbrust-analyzer cargo csscolorparser 0.8.3 utils/hsl_to_rgb().(normalize_anglerust-analyzer cargo csscolorparser 0.8.3 utils/normalize_angle().(h), s.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0), l.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0));
114 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(r, g, b, a)
115 }
116
117 /// Arguments:
118 ///
119 /// * `h`: Hue angle [0..360]
120 /// * `w`: Whiteness [0..1]
121 /// * `b`: Blackness [0..1]
122 /// * `a`: Alpha [0..1]
123 pub const fn from_hwbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_hwba().(h: f32, w: f32, b: f32, a: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
124 let [r, g, b] = hwb_to_rgbrust-analyzer cargo csscolorparser 0.8.3 utils/hwb_to_rgb().(normalize_anglerust-analyzer cargo csscolorparser 0.8.3 utils/normalize_angle().(h), w.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0), b.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0));
125 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(r, g, b, a)
126 }
127
128 /// Arguments:
129 ///
130 /// * `l`: Perceived lightness
131 /// * `a`: How green/red the color is
132 /// * `b`: How blue/yellow the color is
133 /// * `alpha`: Alpha [0..1]
134 pub fn from_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_oklaba().(l: f32, a: f32, b: f32, alpha: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
135 let [r, g, b] = oklab_to_linear_rgbrust-analyzer cargo csscolorparser 0.8.3 utils/oklab_to_linear_rgb().(l, a, b);
136 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_linear_rgba().(r, g, b, alpha)
137 }
138
139 /// Arguments:
140 ///
141 /// * `l`: Perceived lightness
142 /// * `c`: Chroma
143 /// * `h`: Hue angle in radians
144 /// * `alpha`: Alpha [0..1]
145 pub fn from_oklcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_oklcha().(l: f32, c: f32, h: f32, alpha: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
146 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_oklaba().(l, c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().h.cosrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]cos().(), c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().h.sinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]sin().(), alpha)
147 }
148
149 /// Arguments:
150 ///
151 /// * `l`: Lightness
152 /// * `a`: Distance along the `a` axis
153 /// * `b`: Distance along the `b` axis
154 /// * `alpha`: Alpha [0..1]
155 pub fn from_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_laba().(l: f32, a: f32, b: f32, alpha: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
156 let [r, g, b] = lab_to_linear_rgbrust-analyzer cargo csscolorparser 0.8.3 lab/lab_to_linear_rgb().(l, a, b);
157 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_linear_rgba().(r, g, b, alpha)
158 }
159
160 /// Arguments:
161 ///
162 /// * `l`: Lightness
163 /// * `c`: Chroma
164 /// * `h`: Hue angle in radians
165 /// * `alpha`: Alpha [0..1]
166 pub fn from_lcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_lcha().(l: f32, c: f32, h: f32, alpha: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
167 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_laba().(l, c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().h.cosrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]cos().(), c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().h.sinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]sin().(), alpha)
168 }
169
170 /// Create color from CSS color string.
171 ///
172 /// # Examples
173 /// ```
174 /// use csscolorparser::Color;
175 /// # use core::error::Error;
176 /// # fn main() -> Result<(), Box<dyn Error>> {
177 ///
178 /// let c = Color::from_html("rgb(255,0,0)")?;
179 ///
180 /// assert_eq!(c.to_array(), [1.0, 0.0, 0.0, 1.0]);
181 /// assert_eq!(c.to_rgba8(), [255, 0, 0, 255]);
182 /// assert_eq!(c.to_css_hex(), "#ff0000");
183 /// assert_eq!(c.to_css_rgb(), "rgb(255 0 0)");
184 /// # Ok(())
185 /// # }
186 /// ```
187 pub fn from_htmlrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_html().<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(s: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color], ParseColorErrorrust-analyzer cargo csscolorparser 0.8.3 error/ParseColorError#> {
188 parserust-analyzer cargo csscolorparser 0.8.3 parser/parse().(s.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().())
189 }
190
191 /// Restricts R, G, B, A values to the range [0..1].
192 #[must_use = "method returns a new Color and does not mutate the original Color"]
193 pub const fn clamprust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]clamp().(&self) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
194 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
195 rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.: self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
196 grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.: self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
197 brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.: self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
198 arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
199 }
200 }
201
202 /// Returns name if there is a name for this color.
203 ///
204 /// **Note:** It ignores transparency (alpha value).
205 ///
206 /// ```
207 /// use csscolorparser::Color;
208 ///
209 /// assert_eq!(Color::from_rgba8(255, 0, 0, 255).name(), Some("red"));
210 /// assert_eq!(Color::from_rgba8(238, 130, 238, 255).name(), Some("violet"));
211 /// assert_eq!(Color::from_rgba8(90, 150, 200, 255).name(), None);
212 /// ```
213 #[cfg(feature = "named-colors")]
214 pub fn namerust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]name().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'static str> {
215 let rgb = &self.to_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_rgba8().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().;
216 for (&k, v) in NAMED_COLORSrust-analyzer cargo csscolorparser 0.8.3 named_colors/NAMED_COLORS..entriesrust-analyzer cargo phf 0.11.3 ordered_map/impl#[`OrderedMap<K, V>`]entries().() {
217 if v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().rgb {
•218 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(k);
219 }
220 }
221 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
222 }
223
224 /// Returns: `[r, g, b, a]`
225 ///
226 /// * Red, green, blue and alpha in the range [0..1]
227 pub const fn to_arrayrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_array().(&self) -> [f32; 4] {
228 [
229 self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
230 self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
231 self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
232 self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
233 ]
234 }
235
236 /// Returns: `[r, g, b, a]`
237 ///
238 /// * Red, green, blue and alpha in the range [0..255]
239 pub const fn to_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_rgba8().(&self) -> [u8; 4] {
240 [
241 (self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u8,
242 (self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u8,
243 (self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u8,
244 (self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u8,
245 ]
246 }
247
248 /// Returns: `[r, g, b, a]`
249 ///
250 /// * Red, green, blue and alpha in the range [0..65535]
251 pub const fn to_rgba16rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_rgba16().(&self) -> [u16; 4] {
252 [
253 (self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().65535.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u16,
254 (self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().65535.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u16,
255 (self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().65535.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u16,
256 (self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().65535.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5) as u16,
257 ]
258 }
259
260 /// Returns: `[h, s, v, a]`
261 ///
262 /// * `h`: Hue angle [0..360]
263 /// * `s`: Saturation [0..1]
264 /// * `v`: Value [0..1]
265 /// * `a`: Alpha [0..1]
266 pub const fn to_hsvarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_hsva().(&self) -> [f32; 4] {
267 let [h, s, v] = rgb_to_hsvrust-analyzer cargo csscolorparser 0.8.3 utils/rgb_to_hsv().(
268 self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
269 self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
270 self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
271 );
272 [
273 h,
274 s.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
275 v.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
276 self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
277 ]
278 }
279
280 /// Returns: `[h, s, l, a]`
281 ///
282 /// * `h`: Hue angle [0..360]
283 /// * `s`: Saturation [0..1]
284 /// * `l`: Lightness [0..1]
285 /// * `a`: Alpha [0..1]
286 pub const fn to_hslarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_hsla().(&self) -> [f32; 4] {
287 let [h, s, l] = rgb_to_hslrust-analyzer cargo csscolorparser 0.8.3 utils/rgb_to_hsl().(
288 self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
289 self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
290 self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
291 );
292 [
293 h,
294 s.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
295 l.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
296 self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
297 ]
298 }
299
300 /// Returns: `[h, w, b, a]`
301 ///
302 /// * `h`: Hue angle [0..360]
303 /// * `w`: Whiteness [0..1]
304 /// * `b`: Blackness [0..1]
305 /// * `a`: Alpha [0..1]
306 pub const fn to_hwbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_hwba().(&self) -> [f32; 4] {
307 let [h, w, b] = rgb_to_hwbrust-analyzer cargo csscolorparser 0.8.3 utils/rgb_to_hwb().(
308 self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
309 self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
310 self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
311 );
312 [
313 h,
314 w.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
315 b.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
316 self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0),
317 ]
318 }
319
320 /// Returns: `[r, g, b, a]`
321 ///
322 /// * Red, green, blue and alpha in the range [0..1]
323 pub fn to_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_linear_rgba().(&self) -> [f32; 4] {
324 fn to_linearrust-analyzer cargo csscolorparser 0.8.3 color/to_linear().(x: f32) -> f32 {
325 if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]ge().0.04045 {
326 return ((x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.055) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().1.055).powfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]powf().(2.4);
327 }
328 x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().12.92
329 }
330 [
331 to_linearrust-analyzer cargo csscolorparser 0.8.3 color/to_linear().(self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.),
332 to_linearrust-analyzer cargo csscolorparser 0.8.3 color/to_linear().(self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.),
333 to_linearrust-analyzer cargo csscolorparser 0.8.3 color/to_linear().(self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.),
334 self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.,
335 ]
336 }
337
338 /// Returns: `[r, g, b, a]`
339 ///
340 /// * Red, green, blue and alpha in the range [0..255]
341 pub fn to_linear_rgba_u8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_linear_rgba_u8().(&self) -> [u8; 4] {
342 let [r, g, b, a] = self.to_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_linear_rgba().();
343 [
344 (r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().() as u8,
345 (g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().() as u8,
346 (b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().() as u8,
347 (a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().255.0).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().() as u8,
348 ]
349 }
350
351 /// Returns: `[l, a, b, alpha]`
352 pub fn to_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_oklaba().(&self) -> [f32; 4] {
353 let [r, g, b, _] = self.to_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_linear_rgba().();
354 let [l, a, b] = linear_rgb_to_oklabrust-analyzer cargo csscolorparser 0.8.3 utils/linear_rgb_to_oklab().(r, g, b);
355 [l, a, b, self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0)]
356 }
357
358 /// Returns: `[l, c, h, alpha]`
359 pub fn to_oklcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_oklcha().(&self) -> [f32; 4] {
360 let [l, a, b, alpha] = self.to_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_oklaba().();
361 let c = (a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().b).sqrtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]sqrt().();
362 let h = b.atan2rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]atan2().(a);
363 [l, c, h, alpha]
364 }
365
366 /// Returns: `[l, a, b, alpha]`
367 pub fn to_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_laba().(&self) -> [f32; 4] {
368 let [r, g, b, alpha] = self.to_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_linear_rgba().();
369 let [l, a, b] = linear_rgb_to_labrust-analyzer cargo csscolorparser 0.8.3 lab/linear_rgb_to_lab().(r, g, b);
370 [l, a, b, alpha.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0)]
371 }
372
373 /// Returns: `[l, c, h, alpha]`
374 pub fn to_lcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_lcha().(&self) -> [f32; 4] {
375 let [l, a, b, alpha] = self.to_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_laba().();
376 let c = (a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().b).sqrtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]sqrt().();
377 let h = b.atan2rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]atan2().(a);
378 [l, c, h, alpha.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]clamp().(0.0, 1.0)]
379 }
380
381 /// Get CSS RGB hexadecimal color representation
382 pub fn to_css_hexrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_hex().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
383 self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
384 }
385
386 /// Get CSS `rgb()` color representation
387 pub fn to_css_rgbrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_rgb().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
388 let [r, g, b, _] = self.to_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_rgba8().();
389 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("rgb({r} {g} {b}{})", AlphaFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/AlphaFmt#(self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.))
390 }
391
392 /// Get CSS `hsl()` color representation
393 pub fn to_css_hslrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_hsl().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
394 let [h, s, l, alpha] = self.to_hslarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_hsla().();
395 let h = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(h);
396 let s = (s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().100.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5).floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]floor().();
397 let l = (l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().100.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5).floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]floor().();
398 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("hsl({h} {s}% {l}%{})", AlphaFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/AlphaFmt#(alpha))
399 }
400
401 /// Get CSS `hwb()` color representation
402 pub fn to_css_hwbrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_hwb().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
403 let [h, w, b, alpha] = self.to_hwbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_hwba().();
404 let h = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(h);
405 let w = (w rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().100.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5).floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]floor().();
406 let b = (b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().100.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().0.5).floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]floor().();
407 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("hwb({h} {w}% {b}%{})", AlphaFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/AlphaFmt#(alpha))
408 }
409
410 /// Get CSS `oklab()` color representation
411 pub fn to_css_oklabrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_oklab().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
412 let [l, a, b, alpha] = self.to_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_oklaba().();
413 let l = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(l);
414 let a = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(a);
415 let b = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(b);
416 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("oklab({l} {a} {b}{})", AlphaFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/AlphaFmt#(alpha))
417 }
418
419 /// Get CSS `oklch()` color representation
420 pub fn to_css_oklchrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_oklch().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
421 let [l, c, h, alpha] = self.to_oklcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_oklcha().();
422 let l = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(l);
423 let c = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(c);
424 let h = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(normalize_anglerust-analyzer cargo csscolorparser 0.8.3 utils/normalize_angle().(h.to_degreesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]to_degrees().()));
425 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("oklch({l} {c} {h}{})", AlphaFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/AlphaFmt#(alpha))
426 }
427
428 /// Get CSS `lab()` color representation
429 pub fn to_css_labrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_lab().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
430 let [l, a, b, alpha] = self.to_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_laba().();
431 let l = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(l);
432 let a = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(a);
433 let b = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(b);
434 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("lab({l} {a} {b}{})", AlphaFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/AlphaFmt#(alpha))
435 }
436
437 /// Get CSS `lch()` color representation
438 pub fn to_css_lchrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_css_lch().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
439 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::f32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/::constsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/consts/::PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/consts/PI.;
440
441 fn to_degreesrust-analyzer cargo csscolorparser 0.8.3 color/to_degrees().(t: f32) -> f32 {
442 if t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().0.0 {
443 t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/consts/PI. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().180.0
444 } else {
445 360.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().(t.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/consts/PI.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().180.0
446 }
447 }
448
449 let [l, c, h, alpha] = self.to_lcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_lcha().();
450 let l = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(l);
451 let c = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(c);
452 let h = FloatFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/FloatFmt#(to_degreesrust-analyzer cargo csscolorparser 0.8.3 color/to_degrees().(h));
453 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("lch({l} {c} {h}{})", AlphaFmtrust-analyzer cargo csscolorparser 0.8.3 utils/helper/AlphaFmt#(alpha))
454 }
455
456 /// Blend this color with the other one, in the RGB color-space. `t` in the range [0..1].
457 pub const fn interpolate_rgbrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]interpolate_rgb().(&self, other: &Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#, t: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
458 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
459 rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.: self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(other.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().self.rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.),
460 grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.: self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(other.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().self.grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.),
461 brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.: self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(other.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().self.brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.),
462 arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(other.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().self.arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.),
463 }
464 }
465
466 /// Blend this color with the other one, in the linear RGB color-space. `t` in the range [0..1].
467 pub fn interpolate_linear_rgbrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]interpolate_linear_rgb().(&self, other: &Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#, t: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
468 let [r1, g1, b1, a1] = self.to_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_linear_rgba().();
469 let [r2, g2, b2, a2] = other.to_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_linear_rgba().();
470 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_linear_rgbarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_linear_rgba().(
471 r1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(r2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().r1),
472 g1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(g2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().g1),
473 b1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(b2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().b1),
474 a1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(a2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().a1),
475 )
476 }
477
478 /// Blend this color with the other one, in the HSV color-space. `t` in the range [0..1].
479 pub const fn interpolate_hsvrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]interpolate_hsv().(&self, other: &Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#, t: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
480 let [h1, s1, v1, a1] = self.to_hsvarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_hsva().();
481 let [h2, s2, v2, a2] = other.to_hsvarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_hsva().();
482 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_hsvarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_hsva().(
483 interp_anglerust-analyzer cargo csscolorparser 0.8.3 utils/interp_angle().(h1, h2, t),
484 s1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(s2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().s1),
485 v1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(v2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().v1),
486 a1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(a2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().a1),
487 )
488 }
489
490 /// Blend this color with the other one, in the [Oklab](https://bottosson.github.io/posts/oklab/) color-space. `t` in the range [0..1].
491 pub fn interpolate_oklabrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]interpolate_oklab().(&self, other: &Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#, t: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
492 let [l1, a1, b1, alpha1] = self.to_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_oklaba().();
493 let [l2, a2, b2, alpha2] = other.to_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_oklaba().();
494 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_oklabarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_oklaba().(
495 l1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(l2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().l1),
496 a1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(a2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().a1),
497 b1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(b2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().b1),
498 alpha1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(alpha2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().alpha1),
499 )
500 }
501
502 /// Blend this color with the other one, in the Lab color-space. `t` in the range [0..1].
503 pub fn interpolate_labrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]interpolate_lab().(&self, other: &Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#, t: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
504 let [l1, a1, b1, alpha1] = self.to_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_laba().();
505 let [l2, a2, b2, alpha2] = other.to_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_laba().();
506 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_labarust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_laba().(
507 l1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(l2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().l1),
508 a1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(a2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().a1),
509 b1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(b2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().b1),
510 alpha1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(alpha2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().alpha1),
511 )
512 }
513
514 /// Blend this color with the other one, in the LCH color-space. `t` in the range [0..1].
515 pub fn interpolate_lchrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]interpolate_lch().(&self, other: &Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#, t: f32) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color] {
516 let [l1, c1, h1, alpha1] = self.to_lcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_lcha().();
517 let [l2, c2, h2, alpha2] = other.to_lcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_lcha().();
518 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]::from_lcharust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_lcha().(
519 l1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(l2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().l1),
520 c1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(c2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().c1),
521 interp_angle_radrust-analyzer cargo csscolorparser 0.8.3 utils/interp_angle_rad().(h1, h2, t),
522 alpha1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Add<Self>`]add().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().(alpha2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().alpha1),
523 )
524 }
525 }
526
527 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
528 fn defaultrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][Default]default().() -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][Default] {
529 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][Default] {
530 rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.: 0.0,
531 grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.: 0.0,
532 brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.: 0.0,
533 arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: 1.0,
534 }
535 }
536 }
537
538 impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
539 fn fmtrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
540 let [r, g, b, a] = self.to_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]to_rgba8().();
541 if a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().255 {
542 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "#{r:02x}{g:02x}{b:02x}{a:02x}")
543 } else {
544 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "#{r:02x}{g:02x}{b:02x}")
545 }
546 }
547 }
548
549 impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
550 type Errrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][FromStr]Err# = ParseColorErrorrust-analyzer cargo csscolorparser 0.8.3 error/ParseColorError#;
551
552 fn from_strrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][FromStr], Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
553 parserust-analyzer cargo csscolorparser 0.8.3 parser/parse().(s)
554 }
555 }
556
557 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<&str> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
558 type Errorrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<&str>`]Error# = ParseColorErrorrust-analyzer cargo csscolorparser 0.8.3 error/ParseColorError#;
559
560 fn try_fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<&str>`]try_from().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<&str>`], Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<&str>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> {
561 parserust-analyzer cargo csscolorparser 0.8.3 parser/parse().(s)
562 }
563 }
564
565 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
566 type Errorrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<String>`]Error# = ParseColorErrorrust-analyzer cargo csscolorparser 0.8.3 error/ParseColorError#;
567
568 fn try_fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<String>`]try_from().(s: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<String>`], Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`TryFrom<String>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> {
569 parserust-analyzer cargo csscolorparser 0.8.3 parser/parse().(s.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().())
570 }
571 }
572
573 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(f32, f32, f32, f32)> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
574 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(f32, f32, f32, f32)>`]from().((r, g, b, a): (f32, f32, f32, f32)) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(f32, f32, f32, f32)>`] {
575 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(f32, f32, f32, f32)>`] { rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r., grust-analyzer cargo csscolorparser 0.8.3 color/Color#g., brust-analyzer cargo csscolorparser 0.8.3 color/Color#b., arust-analyzer cargo csscolorparser 0.8.3 color/Color#a. }
576 }
577 }
578
579 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(f32, f32, f32)> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
580 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(f32, f32, f32)>`]from().((r, g, b): (f32, f32, f32)) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(f32, f32, f32)>`] {
581 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(f32, f32, f32)>`] { rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r., grust-analyzer cargo csscolorparser 0.8.3 color/Color#g., brust-analyzer cargo csscolorparser 0.8.3 color/Color#b., arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: 1.0 }
582 }
583 }
584
585 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[f32; 4]> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
586 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f32; 4]>`]from().([r, g, b, a]: [f32; 4]) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f32; 4]>`] {
587 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f32; 4]>`] { rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r., grust-analyzer cargo csscolorparser 0.8.3 color/Color#g., brust-analyzer cargo csscolorparser 0.8.3 color/Color#b., arust-analyzer cargo csscolorparser 0.8.3 color/Color#a. }
588 }
589 }
590
591 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[f32; 3]> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
592 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f32; 3]>`]from().([r, g, b]: [f32; 3]) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f32; 3]>`] {
593 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f32; 3]>`] { rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r., grust-analyzer cargo csscolorparser 0.8.3 color/Color#g., brust-analyzer cargo csscolorparser 0.8.3 color/Color#b., arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: 1.0 }
594 }
595 }
596
597 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[f64; 4]> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
598 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f64; 4]>`]from().([r, g, b, a]: [f64; 4]) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f64; 4]>`] {
599 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f64; 4]>`] {
600 rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.: r as f32,
601 grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.: g as f32,
602 brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.: b as f32,
603 arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: a as f32,
604 }
605 }
606 }
607
608 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[f64; 3]> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
609 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f64; 3]>`]from().([r, g, b]: [f64; 3]) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f64; 3]>`] {
610 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[f64; 3]>`] {
611 rrust-analyzer cargo csscolorparser 0.8.3 color/Color#r.: r as f32,
612 grust-analyzer cargo csscolorparser 0.8.3 color/Color#g.: g as f32,
613 brust-analyzer cargo csscolorparser 0.8.3 color/Color#b.: b as f32,
614 arust-analyzer cargo csscolorparser 0.8.3 color/Color#a.: 1.0,
615 }
616 }
617 }
618
619 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(u8, u8, u8, u8)> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
620 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(u8, u8, u8, u8)>`]from().((r, g, b, a): (u8, u8, u8, u8)) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(u8, u8, u8, u8)>`] {
621 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(u8, u8, u8, u8)>`]::from_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_rgba8().(r, g, b, a)
622 }
623 }
624
625 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(u8, u8, u8)> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
626 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(u8, u8, u8)>`]from().((r, g, b): (u8, u8, u8)) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(u8, u8, u8)>`] {
627 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<(u8, u8, u8)>`]::from_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_rgba8().(r, g, b, 255)
628 }
629 }
630
631 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[u8; 4]> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
632 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[u8; 4]>`]from().([r, g, b, a]: [u8; 4]) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[u8; 4]>`] {
633 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[u8; 4]>`]::from_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_rgba8().(r, g, b, a)
634 }
635 }
636
637 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[u8; 3]> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
638 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[u8; 3]>`]from().([r, g, b]: [u8; 3]) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[u8; 3]>`] {
639 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<[u8; 3]>`]::from_rgba8rust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]from_rgba8().(r, g, b, 255)
640 }
641 }
642
643 /// Convert rust-rgb's `RGB<f32>` type into `Color`.
644 #[cfg(feature = "rust-rgb")]
645 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<RGBrust-analyzer cargo rgb 0.8.52 formats/rgb/Rgb#<f32>> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
646 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGB<f32>>`]from().(item: RGBrust-analyzer cargo rgb 0.8.52 formats/rgb/Rgb#<f32>) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGB<f32>>`] {
647 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGB<f32>>`]::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(item.rrust-analyzer cargo rgb 0.8.52 formats/rgb/Rgb#r., item.grust-analyzer cargo rgb 0.8.52 formats/rgb/Rgb#g., item.brust-analyzer cargo rgb 0.8.52 formats/rgb/Rgb#b., 1.0)
648 }
649 }
650
651 /// Convert rust-rgb's `RGBA<f32>` type into `Color`.
652 #[cfg(feature = "rust-rgb")]
653 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<RGBArust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#<f32>> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
654 fn fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGBA<f32>>`]from().(item: RGBArust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#<f32>) -> Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGBA<f32>>`] {
655 Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGBA<f32>>`]::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(item.rrust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#r., item.grust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#g., item.brust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#b., item.arust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#a.)
656 }
657 }
658
659 /// Implement Serde serialization into HEX string
660 #[cfg(feature = "serde")]
661 impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
662 fn serializerust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][Serialize]serialize().<S: Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> {
663 serializer.collect_strrust-analyzer cargo serde_core 1.0.228 ser/Serializer#collect_str().(self)
664 }
665 }
666
667 /// Implement Serde deserialization from string
668 #[cfg(feature = "serde")]
669 impl<'de> Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#<'de> for Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color# {
670 fn deserializerust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`Deserialize<'de>`]deserialize().<D: Deserializerrust-analyzer cargo serde_core 1.0.228 de/Deserializer#<'de>>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde_core 1.0.228 de/Deserializer#Error#> {
671 deserializer.deserialize_strrust-analyzer cargo serde_core 1.0.228 de/Deserializer#deserialize_str().(ColorVisitorrust-analyzer cargo csscolorparser 0.8.3 color/ColorVisitor#)
672 }
673 }
674
675 #[cfg(feature = "serde")]
676 struct ColorVisitorrust-analyzer cargo csscolorparser 0.8.3 color/ColorVisitor#;
677
678 #[cfg(feature = "serde")]
679 impl Visitorrust-analyzer cargo serde_core 1.0.228 de/Visitor#<'_> for ColorVisitorrust-analyzer cargo csscolorparser 0.8.3 color/ColorVisitor# {
680 type Valuerust-analyzer cargo csscolorparser 0.8.3 color/impl#[ColorVisitor][`Visitor<'_>`]Value# = Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#;
681
682 fn expectingrust-analyzer cargo csscolorparser 0.8.3 color/impl#[ColorVisitor][`Visitor<'_>`]expecting().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
683 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("a valid css color")
684 }
685
686 fn visit_strrust-analyzer cargo csscolorparser 0.8.3 color/impl#[ColorVisitor][`Visitor<'_>`]visit_str().<E>(self, v: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo csscolorparser 0.8.3 color/impl#[ColorVisitor][`Visitor<'_>`]::Valuerust-analyzer cargo serde_core 1.0.228 de/Visitor#Value#, E>
687 where
688 E: serderust-analyzer cargo serde 1.0.228 crate/::derust-analyzer cargo serde_core 1.0.228 de/::Errorrust-analyzer cargo serde_core 1.0.228 de/Error#,
689 {
690 Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::from_strrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][FromStr]from_str().(v).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(serderust-analyzer cargo serde 1.0.228 crate/::derust-analyzer cargo serde_core 1.0.228 de/::Errorrust-analyzer cargo serde_core 1.0.228 de/Error#::customrust-analyzer cargo serde_core 1.0.228 de/Error#custom().)
691 }
692 }
693
694 #[cfg(test)]
695 mod trust-analyzer cargo csscolorparser 0.8.3 color/t/ {
696 #[cfg(any(feature = "serde", feature = "rust-rgb"))]
697 use superrust-analyzer cargo csscolorparser 0.8.3 color/::*;
698
699 #[cfg(feature = "rust-rgb")]
700 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
701 fn rust_rgbrust-analyzer cargo csscolorparser 0.8.3 color/t/rust_rgb().() {
702 let rgb = RGBrust-analyzer cargo rgb 0.8.52 formats/rgb/Rgb#::newrust-analyzer cargo rgb 0.8.52 inherent_impls/impl#[`Rgb<T>`]new().(0.0, 0.5, 1.0);
703 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(0.0, 0.5, 1.0, 1.0), Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGB<f32>>`]from().(rgb));
704
705 let rgba = RGBArust-analyzer cargo rgb 0.8.52 formats/rgba/Rgba#::newrust-analyzer cargo rgb 0.8.52 inherent_impls/impl#[`Rgba<T>`]new().(1.0, 0.5, 0.0, 0.5);
706 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(1.0, 0.5, 0.0, 0.5), Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::fromrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color][`From<RGBA<f32>>`]from().(rgba));
707 }
708
709 #[cfg(feature = "serde")]
710 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
711 fn serde_serializerust-analyzer cargo csscolorparser 0.8.3 color/t/serde_serialize().() {
712 let test_data = [
713 "#000000",
714 "#ffffff",
715 "#71fe15",
716 "#d6e3c9",
717 "#ff000000",
718 "#ffff8080",
719 "#6b9fa203",
720 "#0e5e0be6",
721 "#84f9a716",
722 ];
723 for s in test_data {
724 let color = parserust-analyzer cargo csscolorparser 0.8.3 parser/parse().(s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
725 serde_testrust-analyzer cargo serde_test 1.0.177 crate/::assert_ser_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_ser_tokens().(&color, &[serde_testrust-analyzer cargo serde_test 1.0.177 crate/::Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::Strrust-analyzer cargo serde_test 1.0.177 token/Token#Str#(s)]);
726 }
727 }
728
729 #[cfg(feature = "serde")]
730 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
731 fn serde_deserializerust-analyzer cargo csscolorparser 0.8.3 color/t/serde_deserialize().() {
732 let col = Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(0.0, 1.0, 0.0, 1.0);
733 serde_testrust-analyzer cargo serde_test 1.0.177 crate/::assert_de_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_de_tokens().(&col, &[serde_testrust-analyzer cargo serde_test 1.0.177 crate/::Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::Strrust-analyzer cargo serde_test 1.0.177 token/Token#Str#("#00ff00")]);
734 serde_testrust-analyzer cargo serde_test 1.0.177 crate/::assert_de_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_de_tokens().(&col, &[serde_testrust-analyzer cargo serde_test 1.0.177 crate/::Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::Strrust-analyzer cargo serde_test 1.0.177 token/Token#Str#("rgb(0 255 0)")]);
735
736 #[cfg(feature = "named-colors")]
737 {
738 serde_testrust-analyzer cargo serde_test 1.0.177 crate/::assert_de_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_de_tokens().(&col, &[serde_testrust-analyzer cargo serde_test 1.0.177 crate/::Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::Strrust-analyzer cargo serde_test 1.0.177 token/Token#Str#("lime")]);
739
740 let col = Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(1.0, 0.0, 0.0, 1.0);
741 serde_testrust-analyzer cargo serde_test 1.0.177 crate/::assert_de_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_de_tokens().(&col, &[serde_testrust-analyzer cargo serde_test 1.0.177 crate/::Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::Strrust-analyzer cargo serde_test 1.0.177 token/Token#Str#("red")]);
742
743 let col = Colorrust-analyzer cargo csscolorparser 0.8.3 color/Color#::newrust-analyzer cargo csscolorparser 0.8.3 color/impl#[Color]new().(1.0, 1.0, 0.0, 1.0);
744 serde_testrust-analyzer cargo serde_test 1.0.177 crate/::assert_de_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_de_tokens().(&col, &[serde_testrust-analyzer cargo serde_test 1.0.177 crate/::Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::Strrust-analyzer cargo serde_test 1.0.177 token/Token#Str#("yellow")]);
745 }
746 }
747 }