Debian Codegraph @

src/oklab.rs

raw symbols SCIP
1 //! Types for the Oklab color space.
2
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#, fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#};
4
5 pub use alpharust-analyzer cargo palette 0.7.6 oklab/alpha/::Oklabarust-analyzer cargo palette 0.7.6 oklab/alpha/Oklaba#;
6
7 use craterust-analyzer cargo palette 0.7.6 crate/::{
8 anglerust-analyzer cargo palette 0.7.6 angle/::RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#,
9 bool_maskrust-analyzer cargo palette 0.7.6 bool_mask/::HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#,
10 convertrust-analyzer cargo palette 0.7.6 convert/::{FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#, IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#},
11 encodingrust-analyzer cargo palette 0.7.6 encoding/::{IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#, Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#},
12 matrixrust-analyzer cargo palette 0.7.6 matrix/::multiply_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz().,
13 numrust-analyzer cargo palette 0.7.6 num/::{Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#, Hypotrust-analyzer cargo palette 0.7.6 num/Hypot#, MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#, Onerust-analyzer cargo palette 0.7.6 num/One#, Powirust-analyzer cargo palette 0.7.6 num/Powi#, Realrust-analyzer cargo palette 0.7.6 num/Real#, Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#, Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#},
14 ok_utilsrust-analyzer cargo palette 0.7.6 ok_utils/::{toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv()., ChromaValuesrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#, LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#, STrust-analyzer cargo palette 0.7.6 ok_utils/ST#},
15 rgbrust-analyzer cargo palette 0.7.6 rgb/::{Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#, RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#},
16 white_pointrust-analyzer cargo palette 0.7.6 white_point/::D65rust-analyzer cargo palette 0.7.6 white_point/D65#,
17 LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#, Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#, Okhslrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#, Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#, Oklchrust-analyzer cargo palette 0.7.6 oklch/Oklch#, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#,
18 };
19
20 pub use selfrust-analyzer cargo palette 0.7.6 oklab/::propertiesrust-analyzer cargo palette 0.7.6 oklab/properties/::Iterrust-analyzer cargo palette 0.7.6 oklab/properties/Iter#;
21
22 #[cfg(feature = "random")]
23 pub use selfrust-analyzer cargo palette 0.7.6 oklab/::randomrust-analyzer cargo palette 0.7.6 oklab/random/::UniformOklabrust-analyzer cargo palette 0.7.6 oklab/random/UniformOklab#;
24
25 mod alpharust-analyzer cargo palette 0.7.6 oklab/alpha/;
26 mod propertiesrust-analyzer cargo palette 0.7.6 oklab/properties/;
27 #[cfg(feature = "random")]
28 mod randomrust-analyzer cargo palette 0.7.6 oklab/random/;
29 #[cfg(test)]
30 #[cfg(feature = "approx")]
31 mod visual_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/;
32
33 // Using recalculated matrix values from
34 // https://github.com/LeaVerou/color.js/blob/master/src/spaces/oklab.js
35 //
36 // see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
37 // and the following https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-945714988
38
39 /// XYZ to LSM transformation matrix
40 #[rustfmt::skip]
41 fn m1rust-analyzer cargo palette 0.7.6 oklab/m1().<T: Realrust-analyzer cargo palette 0.7.6 num/Real#>() -> Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#<T> {
42 [
43 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.8190224432164319), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3619062562801221), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.12887378261216414),
44 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0329836671980271), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.9292868468965546), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.03614466816999844),
45 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.048177199566046255), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.26423952494422764), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.6335478258136937),
46 ]
47 }
48
49 /// LMS to XYZ transformation matrix
50 #[rustfmt::skip]
51 pub(craterust-analyzer cargo palette 0.7.6 crate/) fn m1_invrust-analyzer cargo palette 0.7.6 oklab/m1_inv().<T: Realrust-analyzer cargo palette 0.7.6 num/Real#>() -> Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#<T> {
52 [
53 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.2268798733741557), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.5578149965554813), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.28139105017721583),
54 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.04057576262431372), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.1122868293970594), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.07171106666151701),
55 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.07637294974672142), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.4214933239627914), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.5869240244272418),
56 ]
57 }
58
59 /// LMS to Oklab transformation matrix
60 #[rustfmt::skip]
61 fn m2rust-analyzer cargo palette 0.7.6 oklab/m2().<T: Realrust-analyzer cargo palette 0.7.6 num/Real#>() -> Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#<T> {
62 [
63 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2104542553), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7936177850), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.0040720468),
64 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.9779984951), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().2.4285922050), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.4505937099),
65 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0259040371), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7827717662), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.8086757660),
66 ]
67 }
68
69 /// Oklab to LMS transformation matrix
70 #[rustfmt::skip]
71 #[allow(clippy::excessive_precision)]
72 pub(craterust-analyzer cargo palette 0.7.6 crate/) fn m2_invrust-analyzer cargo palette 0.7.6 oklab/m2_inv().<T: Realrust-analyzer cargo palette 0.7.6 num/Real#>() -> Mat3rust-analyzer cargo palette 0.7.6 matrix/Mat3#<T> {
73 [
74 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.99999999845051981432), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.39633779217376785678), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.21580375806075880339),
75 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.0000000088817607767), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.1055613423236563494), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.063854174771705903402),
76 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.0000000546724109177), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.089484182094965759684), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.2914855378640917399),
77 ]
78 }
79
80 /// The [Oklab color space](https://bottosson.github.io/posts/oklab/).
81 ///
82 /// # Characteristics
83 /// `Oklab` is a *perceptual* color space. It does not relate to an output
84 /// device (a monitor or printer) but instead relates to the [CIE standard
85 /// observer](https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_standard_observer)
86 /// -- an averaging of the results of color matching experiments under
87 /// laboratory conditions.
88 ///
89 /// `Oklab` is a uniform color space ([Compare to the HSV color
90 /// space](https://bottosson.github.io/posts/oklab/#comparing-oklab-to-hsv)). It
91 /// is useful for things like:
92 /// * Turning an image grayscale, while keeping the perceived lightness the same
93 /// * Increasing the saturation of colors, while maintaining perceived hue and
94 /// lightness
95 /// * Creating smooth and uniform looking transitions between colors
96 ///
97 /// `Oklab`'s structure is similar to [L\*a\*b\*](crate::Lab). It is based on
98 /// the [opponent color model of human
99 /// vision](https://en.wikipedia.org/wiki/Opponent_process), where red and green
100 /// form an opponent pair, and blue and yellow form an opponent pair.
101 ///
102 /// `Oklab` uses [D65](https://en.wikipedia.org/wiki/Illuminant_D65)'s
103 /// whitepoint -- daylight illumination, which is also used by sRGB, rec2020 and
104 /// Display P3 color spaces -- and assumes normal well-lit viewing conditions,
105 /// to which the eye is adapted. Thus `Oklab`s lightness `l` technically is a
106 /// measure of relative brightness -- a subjective measure -- not relative
107 /// luminance. The lightness is scale/exposure-independend, i.e. independent of
108 /// the actual luminance of the color, as displayed by some medium, and even for
109 /// blindingly bright colors or very bright or dark viewing conditions assumes,
110 /// that the eye is adapted to the color's luminance and the hue and chroma are
111 /// perceived linearly.
112 ///
113 ///
114 /// `Oklab`'s chroma is unlimited. Thus it can represent colors of any color
115 /// space (including HDR). `l` is in the range `0.0 .. 1.0` and `a` and `b` are
116 /// unbounded.
117 ///
118 /// # Conversions
119 /// [`Oklch`] is a cylindrical form of `Oklab`.
120 ///
121 /// `Oklab` colors converted from valid (i.e. clamped) `sRGB` will be in the
122 /// `sRGB` gamut.
123 ///
124 /// [`Okhsv`], [`Okhwb`][crate::Okhsv] and [`Okhsl`] reference the `sRGB` gamut.
125 /// The transformation from `Oklab` to one of them is based on the assumption,
126 /// that the transformed `Oklab` value is within `sRGB`.
127 ///
128 /// `Okhsv`, `Okhwb` and `Okhsl` are not applicable to HDR, which also come with
129 /// color spaces with wider gamuts. They require [additional
130 /// research](https://bottosson.github.io/posts/colorpicker/#ideas-for-future-work).
131 ///
132 /// When a `Oklab` color is converted from [`Srgb`](crate::rgb::Srgb) or a
133 /// equivalent color space, e.g. [`Hsv`][crate::Hsv], [`Okhsv`],
134 /// [`Hsl`][crate::Hsl], [`Okhsl`], [`Hwb`][crate::Hwb],
135 /// [`Okhwb`][crate::Okhwb], it's lightness will be relative to the (user
136 /// controlled) maximum contrast and luminance of the display device, to which
137 /// the eye is assumed to be adapted.
138 ///
139 /// # Clamping
140 /// [`Clamp`][crate::Clamp]ing will only clamp `l`. Clamping does not guarantee
141 /// the color to be inside the perceptible or any display-dependent color space
142 /// (like *sRGB*).
143 ///
144 /// To ensure a color is within the *sRGB* gamut, it can first be converted to
145 /// `Okhsv`, clamped there and converted it back to `Oklab`.
146 ///
147 /// ```
148 /// # use approx::assert_abs_diff_eq;
149 /// # use palette::{convert::FromColorUnclamped,IsWithinBounds, LinSrgb, Okhsv, Oklab};
150 /// # use palette::Clamp;
151 /// // Display P3 yellow according to https://colorjs.io/apps/convert/?color=color(display-p3%201%201%200)&precision=17
152 /// let oklab = Oklab::from_color_unclamped(LinSrgb::new(1.0, 1.0, -0.098273600140966));
153 /// let okhsv: Okhsv<f64> = Okhsv::from_color_unclamped(oklab);
154 /// assert!(!okhsv.is_within_bounds());
155 /// let clamped_okhsv = okhsv.clamp();
156 /// assert!(clamped_okhsv.is_within_bounds());
157 /// let linsrgb = LinSrgb::from_color_unclamped(clamped_okhsv);
158 /// let expected = LinSrgb::new(1.0, 0.9876530763223166, 0.0);
159 /// assert_abs_diff_eq!(expected, linsrgb, epsilon = 0.02);
160 /// ```
161 /// Since the conversion contains a gamut mapping, it will map the color to one
162 /// of the perceptually closest locations in the `sRGB` gamut. Gamut mapping --
163 /// unlike clamping -- is an expensive operation. To get computationally cheaper
164 /// (and perceptually much worse) results, convert directly to [`Srgb`] and
165 /// clamp there.
166 ///
167 /// # Lightening / Darkening
168 /// [`Lighten`](crate::Lighten)ing and [`Darken`](crate::Darken)ing will change
169 /// `l`, as expected. However, either operation may leave an implicit color
170 /// space (the percetible or a display dependent color space like *sRGB*).
171 ///
172 /// To ensure a color is within the *sRGB* gamut, first convert it to `Okhsl`,
173 /// lighten/darken it there and convert it back to `Oklab`.
174
175 #[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:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, ArrayCastrust-analyzer cargo palette_derive 0.7.6 ArrayCast:, FromColorUnclampedrust-analyzer cargo palette_derive 0.7.6 FromColorUnclamped:, WithAlpharust-analyzer cargo palette_derive 0.7.6 WithAlpha:)]
176 #[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))]
177 #[palette(
178 palette_internal,
179 white_point = "D65",
180 component = "T",
181 skip_derives(Oklab, Oklch, Okhsv, Okhsl, Xyz, Rgb)
182 )]
183 #[repr(C)]
184 pub struct Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T = f32> {
185 /// `l` is the lightness of the color. `0` gives absolute black and `1` gives the
186 /// full white point luminance of the display medium.
187 ///
188 /// [`D65` (normalized with Y=1, i.e. white according to the adaption of the
189 /// eye) transforms to
190 /// L=1,a=0,b=0](https://bottosson.github.io/posts/oklab/#how-oklab-was-derived).
191 /// However intermediate values differ from those of CIELab non-linearly.
192 pub lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l.: T,
193
194 /// `a` changes the hue from reddish to greenish, when moving from positive
195 /// to negative values and becomes more intense with larger absolute values.
196 ///
197 /// The exact orientation is determined by `b`
198 pub arust-analyzer cargo palette 0.7.6 oklab/Oklab#a.: T,
199
200 /// `b` changes the hue from yellowish to blueish, when moving from positive
201 /// to negative values and becomes more intense with larger absolute values.
202 ///
203 /// [Positive b is oriented to the same yellow color as
204 /// CAM16](https://bottosson.github.io/posts/oklab/#how-oklab-was-derived)
205 pub brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.: T,
206 }
207
208 impl<T> Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T> {
209 /// Create an Oklab color.
210 pub const fn newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(l: T, a: T, b: T) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`] {
211 Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`] { lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., brust-analyzer cargo palette 0.7.6 oklab/Oklab#b. }
212 }
213
214 /// Convert to a `(L, a, b)` tuple.
215 pub fn into_componentsrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]into_components().(self) -> (T, T, T) {
216 (self.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., self.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., self.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.)
217 }
218
219 /// Convert from a `(L, a, b)` tuple.
220 pub fn from_componentsrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]from_components().((l, a, b): (T, T, T)) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`] {
221 Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(l, a, b)
222 }
223 }
224
225 // component bounds
226 // For `Oklab` in general a and b are unbounded.
227 // In the sRGB gamut `Oklab`s chroma (and thus a and b) are bounded.
228 impl<T> Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
229 where
230 T: Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Onerust-analyzer cargo palette 0.7.6 num/One#,
231 {
232 /// Return the `l` value minimum.
233 pub fn min_lrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]min_l().() -> T {
234 T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()
235 }
236
237 /// Return the `l` value maximum.
238 pub fn max_lrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]max_l().() -> T {
239 T::onerust-analyzer cargo palette 0.7.6 num/One#one().()
240 }
241 }
242
243 impl_reference_component_methodsrust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, [lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.]);
244 impl_struct_of_arrays_methodsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, [l, a, b]);
245
246 impl<T> Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
247 where
248 T: Hypotrust-analyzer cargo palette 0.7.6 num/Hypot# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
249 {
250 /// Returns the chroma.
251 pub(craterust-analyzer cargo palette 0.7.6 crate/) fn get_chromarust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]get_chroma().(&self) -> T {
252 T::hypotrust-analyzer cargo palette 0.7.6 num/Hypot#hypot().(self.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), self.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())
253 }
254 }
255
256 impl<T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T> {
257 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Self>`]from_color_unclamped().(color: Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Self>`]) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Self>`] {
258 color
259 }
260 }
261
262 impl<T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T>> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
263 where
264 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#,
265 {
266 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Xyz<D65, T>>`]from_color_unclamped().(color: Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T>) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Xyz<D65, T>>`] {
267 let m1 = m1rust-analyzer cargo palette 0.7.6 oklab/m1().();
268 let m2 = m2rust-analyzer cargo palette 0.7.6 oklab/m2().();
269
270 let Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz# {
271 xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x.: l, yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.: m, zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.: s, ..
272 } = multiply_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz().(m1, color.with_white_pointrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]with_white_point().());
273
274 let l_m_s_ = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(l.cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().(), m.cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().(), s.cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().());
275
276 let Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz# {
277 xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x.: l, yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.: a, zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.: b, ..
278 } = multiply_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz().(m2, l_m_s_);
279
280 Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Xyz<D65, T>>`]::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(l, a, b)
281 }
282 }
283
284 fn linear_srgb_to_oklabrust-analyzer cargo palette 0.7.6 oklab/linear_srgb_to_oklab().<T>(c: LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>) -> Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
285 where
286 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#,
287 {
288 let l = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.4122214708) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.
289 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5363325363) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.
290 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0514459929) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.;
291 let m = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2119034982) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.
292 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.6806995451) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.
293 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.1073969566) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.;
294 let s = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0883024619) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.
295 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2817188376) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.
296 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.6299787005) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.;
297
298 let l_ = l.cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().();
299 let m_ = m.cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().();
300 let s_ = s.cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().();
301
302 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(
303 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2104542553) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7936177850) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_
304 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0040720468) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_,
305 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.9779984951) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.4285922050) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_
306 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.4505937099) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_,
307 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0259040371) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7827717662) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_
308 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.8086757660) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_,
309 )
310 }
311
312 pub(craterust-analyzer cargo palette 0.7.6 crate/) fn oklab_to_linear_srgbrust-analyzer cargo palette 0.7.6 oklab/oklab_to_linear_srgb().<T>(c: Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>) -> LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>
313 where
314 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#,
315 {
316 let l_ = c.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3963377774) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2158037573) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.;
317 let m_ = c.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.1055613458) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0638541728) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.;
318 let s_ = c.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.0894841775) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.2914855480) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.;
319
320 let l = l_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_;
321 let m = m_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m_;
322 let s = s_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_ rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_;
323
324 LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(
325 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0767416621) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.3077115913) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m
326 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.2309699292) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s,
327 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.2684380046) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.6097574011) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m
328 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.3413193965) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s,
329 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.0041960863) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.7034186147) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().m
330 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.7076147010) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s,
331 )
332 }
333
334 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
335 where
336 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#,
337 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#,
338 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, T>,
339 S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#<WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint# = D65rust-analyzer cargo palette 0.7.6 white_point/D65#> + 'static,
340 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>>,
341 {
342 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(rgb: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`] {
343 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<<S as RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#>::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>() {
344 // Use direct sRGB to Oklab conversion
345 // Rounding errors are likely a contributing factor to differences.
346 // Also the conversion via XYZ doesn't use pre-defined matrices (yet)
347 linear_srgb_to_oklabrust-analyzer cargo palette 0.7.6 oklab/linear_srgb_to_oklab().(rgb.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().().reinterpret_asrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]reinterpret_as().())
348 } else {
349 // Convert via XYZ
350 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(rgb).into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/impl#[T][`IntoColorUnclamped<U>`]into_color_unclamped().()
351 }
352 }
353 }
354
355 impl<T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Oklchrust-analyzer cargo palette 0.7.6 oklch/Oklch#<T>> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
356 where
357 T: RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# + Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry# + Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = T> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
358 {
359 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Oklch<T>>`]from_color_unclamped().(color: Oklchrust-analyzer cargo palette 0.7.6 oklch/Oklch#<T>) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Oklch<T>>`] {
360 let (a, b) = color.huerust-analyzer cargo palette 0.7.6 oklch/Oklch#hue..into_cartesianrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]into_cartesian().();
361 let chroma = color.chromarust-analyzer cargo palette 0.7.6 oklch/Oklch#chroma..maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().());
362
363 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab# {
364 lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l.: color.lrust-analyzer cargo palette 0.7.6 oklch/Oklch#l.,
365 arust-analyzer cargo palette 0.7.6 oklab/Oklab#a.: a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().chroma.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
366 brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.: b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().chroma,
367 }
368 }
369 }
370
371 /// # See
372 /// See [`okhsl_to_srgb`](https://bottosson.github.io/posts/colorpicker/#hsl-2)
373 impl<T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Okhslrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#<T>> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
374 where
375 T: RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#
376 + Onerust-analyzer cargo palette 0.7.6 num/One#
377 + Zerorust-analyzer cargo palette 0.7.6 num/Zero#
378 + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#
379 + Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#
380 + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#
381 + PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#
382 + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool>
383 + Powirust-analyzer cargo palette 0.7.6 num/Powi#
384 + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#
385 + Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry#
386 + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
387 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>>,
388 {
389 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Okhsl<T>>`]from_color_unclamped().(hsl: Okhslrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#<T>) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Okhsl<T>>`] {
390 let h = hsl.huerust-analyzer cargo palette 0.7.6 okhsl/Okhsl#hue.;
391 let s = hsl.saturationrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#saturation.;
392 let l = hsl.lightnessrust-analyzer cargo palette 0.7.6 okhsl/Okhsl#lightness.;
393
394 if l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().T::onerust-analyzer cargo palette 0.7.6 num/One#one().() {
395 return Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().(), T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().());
396 } else if l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() {
397 return Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().());
398 }
399
400 let (a_, b_) = h.into_cartesianrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]into_cartesian().();
401 let oklab_lightness = toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv().(l);
402
403 let cs = ChromaValuesrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#::from_normalizedrust-analyzer cargo palette 0.7.6 ok_utils/impl#[`ChromaValues<T>`]from_normalized().(oklab_lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), b_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
404
405 // Interpolate the three values for C so that:
406 // At s=0: dC/ds = cs.zero, C = 0
407 // At s=0.8: C = cs.mid
408 // At s=1.0: C = cs.max
409
410 let mid = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.8);
411 let mid_inv = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.25);
412
413 let chroma = if s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().mid {
414 let t = mid_inv rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s;
415
416 let k_1 = mid rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().cs.zerorust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#zero.;
417 let k_2 = T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().k_1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().cs.midrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#mid.;
418
419 t.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().k_2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().t)
420 } else {
421 let t = (s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&mid) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().&mid);
422
423 let k_0 = cs.midrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#mid..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().();
424 let k_1 = (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().mid) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&cs.midrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#mid. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&cs.midrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#mid. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&mid_inv rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().mid_inv rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().cs.zerorust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#zero.;
425 let k_2 = T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().k_1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(cs.maxrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#max. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().cs.midrust-analyzer cargo palette 0.7.6 ok_utils/ChromaValues#mid.);
426
427 k_0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().t.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k_1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().k_2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().t)
428 };
429
430 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(oklab_lightness, chroma.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().a_, chroma rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b_)
431 }
432 }
433
434 impl<T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#<T>> for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
435 where
436 T: RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#
437 + PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#
438 + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool>
439 + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#
440 + Powirust-analyzer cargo palette 0.7.6 num/Powi#
441 + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#
442 + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#
443 + Onerust-analyzer cargo palette 0.7.6 num/One#
444 + Zerorust-analyzer cargo palette 0.7.6 num/Zero#
445 + Cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#
446 + Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry#,
447 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T>>,
448 {
449 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Okhsv<T>>`]from_color_unclamped().(hsv: Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#<T>) -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Okhsv<T>>`] {
450 if hsv.valuerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#value. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() {
451 // pure black
452 return Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Okhsv<T>>`] {
453 lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l.: T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
454 arust-analyzer cargo palette 0.7.6 oklab/Oklab#a.: T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
455 brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.: T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
456 };
457 }
458
459 if hsv.saturationrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#saturation. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() {
460 // totally desaturated color -- the triangle is just the 0-chroma-line
461 let l = toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv().(hsv.valuerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#value.);
462 return Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Okhsv<T>>`] {
463 lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l.,
464 arust-analyzer cargo palette 0.7.6 oklab/Oklab#a.: T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
465 brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.: T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
466 };
467 }
468
469 let h_radians = hsv.huerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#hue..into_raw_radiansrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]into_raw_radians().();
470 let a_ = T::cosrust-analyzer cargo palette 0.7.6 num/Trigonometry#cos().(h_radians.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
471 let b_ = T::sinrust-analyzer cargo palette 0.7.6 num/Trigonometry#sin().(h_radians);
472
473 let cusp = LCrust-analyzer cargo palette 0.7.6 ok_utils/LC#::find_cusprust-analyzer cargo palette 0.7.6 ok_utils/impl#[`LC<T>`]find_cusp().(a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), b_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
474 let cusp: STrust-analyzer cargo palette 0.7.6 ok_utils/ST#<T> = cusp.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
475 let s_0 = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5);
476 let k = T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().s_0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().cusp.srust-analyzer cargo palette 0.7.6 ok_utils/ST#s.;
477
478 // first we compute L and V as if the gamut is a perfect triangle
479
480 // L, C, when v == 1:
481 let l_v = T::onerust-analyzer cargo palette 0.7.6 num/One#one().()
482 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().hsv.saturationrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#saturation..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().s_0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()
483 /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(s_0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&cusp.trust-analyzer cargo palette 0.7.6 ok_utils/ST#t. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().cusp.trust-analyzer cargo palette 0.7.6 ok_utils/ST#t..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&hsv.saturationrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#saturation.);
484 let c_v =
485 hsv.saturationrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#saturation..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&cusp.trust-analyzer cargo palette 0.7.6 ok_utils/ST#t. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&s_0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().(s_0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&cusp.trust-analyzer cargo palette 0.7.6 ok_utils/ST#t. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().cusp.trust-analyzer cargo palette 0.7.6 ok_utils/ST#t. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().hsv.saturationrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#saturation.);
486
487 // then we compensate for both toe and the curved top part of the triangle:
488 let l_vt = toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv().(l_v.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
489 let c_vt = c_v.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&l_vt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().&l_v;
490
491 let mut lightness = hsv.valuerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#value..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().l_v;
492 let mut chroma = hsv.valuerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#value. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c_v;
493 let lightness_new = toe_invrust-analyzer cargo palette 0.7.6 ok_utils/toe_inv().(lightness.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
494 chroma = chroma rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&lightness_new rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().lightness;
495 // the values may be outside the normal range
496 let rgb_scale: LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#<T> =
497 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(l_vt, a_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&c_vt, b_.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().c_vt).into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#into_color_unclamped().();
498 let lightness_scale_factor = T::cbrtrust-analyzer cargo palette 0.7.6 num/Cbrt#cbrt().(
499 T::onerust-analyzer cargo palette 0.7.6 num/One#one().()
500 /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().T::maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(
501 T::maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(rgb_scale.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., rgb_scale.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.),
502 T::maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(rgb_scale.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue., T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()),
503 ),
504 );
505
506 lightness = lightness_new rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&lightness_scale_factor;
507 chroma = chroma rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().lightness_scale_factor;
508
509 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(lightness, chroma.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().a_, chroma rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().b_)
510 }
511 }
512
513 impl_tuple_conversionrust-analyzer cargo palette 0.7.6 macros/convert/impl_tuple_conversion!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab# as (T, T, T));
514
515 impl<T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
516 where
517 T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#,
518 {
519 type Maskrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#;
520 }
521
522 impl<T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>
523 where
524 T: Zerorust-analyzer cargo palette 0.7.6 num/Zero#,
525 {
526 fn defaultrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][Default]default().() -> Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][Default] {
527 Selfrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][Default]::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().())
528 }
529 }
530
531 #[cfg(feature = "bytemuck")]
532 unsafe impl<T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {}
533
534 #[cfg(feature = "bytemuck")]
535 unsafe impl<T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {}
536
537 #[cfg(test)]
538 mod testrust-analyzer cargo palette 0.7.6 oklab/test/ {
539 use craterust-analyzer cargo palette 0.7.6 crate/::Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#;
540
541 test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#);
542
543 #[cfg(feature = "approx")]
544 mod conversionrust-analyzer cargo palette 0.7.6 oklab/test/conversion/ {
545 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#;
546
547 use craterust-analyzer cargo palette 0.7.6 crate/::{
548 convertrust-analyzer cargo palette 0.7.6 convert/::FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#, rgbrust-analyzer cargo palette 0.7.6 rgb/::Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#, visualrust-analyzer cargo palette 0.7.6 visual/::VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#, white_pointrust-analyzer cargo palette 0.7.6 white_point/::D65rust-analyzer cargo palette 0.7.6 white_point/D65#,
549 FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, Labrust-analyzer cargo palette 0.7.6 lab/Lab#, LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#,
550 };
551
552 /// Asserts that, for any color space, the lightness of pure white is converted to `l == 1.0`
553 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
554 fn lightness_of_white_is_onerust-analyzer cargo palette 0.7.6 oklab/test/conversion/lightness_of_white_is_one().() {
555 let rgb: Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<f64> = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#ffffff").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().();
556 let lin_rgb = LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S1, T>`][`FromColorUnclamped<Rgb<S2, T>>`]from_color_unclamped().(rgb);
557 let oklab = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(lin_rgb);
558 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("white {rgb:?} == {oklab:?}");
559 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., 1.0, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-7);
560 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., 0.0, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-7);
561 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b., 0.0, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-7);
562
563 let lab: Labrust-analyzer cargo palette 0.7.6 lab/Lab#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64> = Labrust-analyzer cargo palette 0.7.6 lab/Lab#::from_componentsrust-analyzer cargo palette 0.7.6 lab/impl#[`Lab<Wp, T>`]from_components().((100.0, 0.0, 0.0));
564 let rgb: Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<f64> = Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<crate::Lab<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>>`]from_color_unclamped().(lab);
565 let oklab = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<crate::Lab<D65, T>>`]from_color_unclamped().(lab);
566 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("white {lab:?} == {rgb:?} == {oklab:?}");
567 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., 1.0, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-4);
568 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., 0.0, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-4);
569 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b., 0.0, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-4);
570 }
571
572 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
573 fn blue_srgbrust-analyzer cargo palette 0.7.6 oklab/test/conversion/blue_srgb().() {
574 // use f64 to be comparable to javascript
575 let rgb: Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#<f64> = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#0000ff").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().();
576 let lin_rgb = LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S1, T>`][`FromColorUnclamped<Rgb<S2, T>>`]from_color_unclamped().(rgb);
577 let oklab = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(lin_rgb);
578
579 // values from Ok Color Picker, which seems to use Björn Ottosson's original
580 // algorithm (from the direct srgb2oklab conversion, not via the XYZ color space)
581 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., 0.4520137183853429, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-9);
582 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.03245698416876397, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-9);
583 assert_abs_diff_eqrust-analyzer cargo approx 0.5.1 macros/assert_abs_diff_eq!!(oklab.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b., -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.3115281476783751, epsilonrust-analyzer cargo approx 0.5.1 impl#[`AbsDiff<A, B>`]epsilon(). = 1e-9);
584 }
585
586 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
587 fn redrust-analyzer cargo palette 0.7.6 oklab/test/conversion/red().() {
588 let a = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1.0, 0.0, 0.0));
589 // from https://github.com/bottosson/bottosson.github.io/blob/master/misc/ok_color.h
590 let b = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.6279553606145516, 0.22486306106597395, 0.1258462985307351);
591 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(a, b, 1e-8));
592 }
593
594 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
595 fn greenrust-analyzer cargo palette 0.7.6 oklab/test/conversion/green().() {
596 let a = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.0, 1.0, 0.0));
597 // from https://github.com/bottosson/bottosson.github.io/blob/master/misc/ok_color.h
598 let b = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(
599 0.8664396115356694,
600 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.23388757418790812,
601 0.17949847989672985,
602 );
603 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(a, b, 1e-8));
604 }
605
606 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
607 fn bluerust-analyzer cargo palette 0.7.6 oklab/test/conversion/blue().() {
608 let a = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.0, 0.0, 1.0));
609 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Oklab blue: {:?}", a);
610 // from https://github.com/bottosson/bottosson.github.io/blob/master/misc/ok_color.h
611 let b = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.4520137183853429, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.0324569841687640, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().0.3115281476783751);
612 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(a, b, 1e-8));
613 }
614 }
615
616 #[cfg(feature = "approx")]
617 mod visually_eqrust-analyzer cargo palette 0.7.6 oklab/test/visually_eq/ {
618 use craterust-analyzer cargo palette 0.7.6 crate/::{visualrust-analyzer cargo palette 0.7.6 visual/::VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#};
619
620 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
621 fn black_eq_different_blackrust-analyzer cargo palette 0.7.6 oklab/test/visually_eq/black_eq_different_black().() {
622 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(
623 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.0, 1.0, 0.0),
624 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.0, 0.0, 1.0),
625 1e-8
626 ));
627 }
628
629 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
630 fn white_eq_different_whiterust-analyzer cargo palette 0.7.6 oklab/test/visually_eq/white_eq_different_white().() {
631 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(
632 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(1.0, 1.0, 0.0),
633 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(1.0, 0.0, 1.0),
634 1e-8
635 ));
636 }
637
638 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
639 fn white_ne_blackrust-analyzer cargo palette 0.7.6 oklab/test/visually_eq/white_ne_black().() {
640 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(
641 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(1.0, 1.0, 0.0),
642 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.0, 0.0, 1.0),
643 1e-8
644 ));
645 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(
646 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(1.0, 1.0, 0.0),
647 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.0, 1.0, 0.0),
648 1e-8
649 ));
650 }
651
652 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
653 fn non_bw_neq_different_non_bwrust-analyzer cargo palette 0.7.6 oklab/test/visually_eq/non_bw_neq_different_non_bw().() {
654 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(
655 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.3, 1.0, 0.0),
656 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.3, 0.0, 1.0),
657 1e-8
658 ));
659 }
660 }
661
662 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
663 fn rangesrust-analyzer cargo palette 0.7.6 oklab/test/ranges().() {
664 assert_rangesrust-analyzer cargo palette 0.7.6 macros/clamp/assert_ranges!! {
665 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<f64>;
666 clamped {
667 l: 0.0 => 1.0
668 // a and b are unbounded --> not part of test
669 }
670 clamped_min {}
671 unclamped {}
672 };
673 }
674
675 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
676 fn check_min_max_componentsrust-analyzer cargo palette 0.7.6 oklab/test/check_min_max_components().() {
677 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::<f32>::min_lrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]min_l().(), 0.0);
678 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::<f32>::max_lrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]max_l().(), 1.0);
679 }
680
681 struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!(
682 Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#[lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.],
683 superrust-analyzer cargo palette 0.7.6 oklab/::Oklabarust-analyzer cargo palette 0.7.6 oklab/alpha/Oklaba#::newrust-analyzer cargo palette 0.7.6 oklab/alpha/impl#[`Alpha<Oklab<T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4),
684 superrust-analyzer cargo palette 0.7.6 oklab/::Oklabarust-analyzer cargo palette 0.7.6 oklab/alpha/Oklaba#::newrust-analyzer cargo palette 0.7.6 oklab/alpha/impl#[`Alpha<Oklab<T>, A>`]new().(0.2, 0.3, 0.4, 0.5),
685 superrust-analyzer cargo palette 0.7.6 oklab/::Oklabarust-analyzer cargo palette 0.7.6 oklab/alpha/Oklaba#::newrust-analyzer cargo palette 0.7.6 oklab/alpha/impl#[`Alpha<Oklab<T>, A>`]new().(0.3, 0.4, 0.5, 0.6)
686 );
687
688 #[cfg(feature = "serializing")]
689 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
690 fn serializerust-analyzer cargo palette 0.7.6 oklab/test/serialize().() {
691 let serialized = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::to_stringrust-analyzer cargo serde_json 1.0.116 ser/to_string().(&Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.3, 0.8, 0.1)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
692
693 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#"{"l":0.3,"a":0.8,"b":0.1}"#);
694 }
695
696 #[cfg(feature = "serializing")]
697 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
698 fn deserializerust-analyzer cargo palette 0.7.6 oklab/test/deserialize().() {
699 let deserialized: Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab# = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::from_strrust-analyzer cargo serde_json 1.0.116 de/from_str().(r#"{"l":0.3,"a":0.8,"b":0.1}"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
700
701 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::newrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`]new().(0.3, 0.8, 0.1));
702 }
703
704 test_uniform_distributionrust-analyzer cargo palette 0.7.6 macros/random/test_uniform_distribution!! {
705 Oklab {
706 l: (0.0, 1.0),
707 a: (-1.0, 1.0),
708 b: (-1.0, 1.0)
709 },
710 min: Oklab::new(0.0, -1.0, -1.0),
711 max: Oklab::new(1.0, 1.0, 1.0)
712 }
713 }