| 1 | //! Types for the CIE L\*C\*h° color space. |
| 2 | |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{ |
| 4 | markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 5 | opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{BitAndrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#, BitOrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#}, |
| 6 | }; |
| 7 | |
| 8 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 9 | anglerust-analyzer cargo palette 0.7.6 angle/::RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#, |
| 10 | bool_maskrust-analyzer cargo palette 0.7.6 bool_mask/::{HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#}, |
| 11 | color_differencerust-analyzer cargo palette 0.7.6 color_difference/::{get_ciede2000_differencerust-analyzer cargo palette 0.7.6 color_difference/get_ciede2000_difference()., Ciede2000rust-analyzer cargo palette 0.7.6 color_difference/Ciede2000#, DeltaErust-analyzer cargo palette 0.7.6 color_difference/DeltaE#, ImprovedDeltaErust-analyzer cargo palette 0.7.6 color_difference/ImprovedDeltaE#, LabColorDiffrust-analyzer cargo palette 0.7.6 color_difference/LabColorDiff#}, |
| 12 | 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#}, |
| 13 | huesrust-analyzer cargo palette 0.7.6 hues/::LabHueIterrust-analyzer cargo palette 0.7.6 hues/LabHueIter#, |
| 14 | numrust-analyzer cargo palette 0.7.6 num/::{Absrust-analyzer cargo palette 0.7.6 num/Abs#, Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, Exprust-analyzer cargo palette 0.7.6 num/Exp#, Hypotrust-analyzer cargo palette 0.7.6 num/Hypot#, Onerust-analyzer cargo palette 0.7.6 num/One#, PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, 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#}, |
| 15 | white_pointrust-analyzer cargo palette 0.7.6 white_point/::D65rust-analyzer cargo palette 0.7.6 white_point/D65#, |
| 16 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#, FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, GetHuerust-analyzer cargo palette 0.7.6 GetHue#, Labrust-analyzer cargo palette 0.7.6 lab/Lab#, LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#, |
| 17 | }; |
| 18 | |
| 19 | /// CIE L\*C\*h° with an alpha component. See the [`Lcha` implementation in |
| 20 | /// `Alpha`](crate::Alpha#Lcha). |
| 21 | pub type Lcharust-analyzer cargo palette 0.7.6 lch/Lcha#<Wp = D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T = f32> = Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T>, T>; |
| 22 | |
| 23 | /// CIE L\*C\*h°, a polar version of [CIE L\*a\*b\*](crate::Lab). |
| 24 | /// |
| 25 | /// L\*C\*h° shares its range and perceptual uniformity with L\*a\*b\*, but |
| 26 | /// it's a cylindrical color space, like [HSL](crate::Hsl) and |
| 27 | /// [HSV](crate::Hsv). This gives it the same ability to directly change |
| 28 | /// the hue and colorfulness of a color, while preserving other visual aspects. |
| 29 | #[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:, 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:)] |
| 30 | #[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 31 | #[palette( |
| 32 | palette_internal, |
| 33 | white_point = "Wp", |
| 34 | component = "T", |
| 35 | skip_derives(Lab, Lch) |
| 36 | )] |
| 37 | #[repr(C)] |
| 38 | pub struct Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp = D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T = f32> { |
| 39 | /// L\* is the lightness of the color. 0.0 gives absolute black and 100.0 |
| 40 | /// gives the brightest white. |
| 41 | pub lrust-analyzer cargo palette 0.7.6 lch/Lch#l.: T, |
| 42 | |
| 43 | /// C\* is the colorfulness of the color. It's similar to saturation. 0.0 |
| 44 | /// gives gray scale colors, and numbers around 128-181 gives fully |
| 45 | /// saturated colors. The upper limit of 128 should |
| 46 | /// include the whole L\*a\*b\* space and some more. |
| 47 | pub chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma.: T, |
| 48 | |
| 49 | /// The hue of the color, in degrees. Decides if it's red, blue, purple, |
| 50 | /// etc. |
| 51 | #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_same_layout_as = "T")] |
| 52 | pub huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.: LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>, |
| 53 | |
| 54 | /// The white point associated with the color's illuminant and observer. |
| 55 | /// D65 for 2 degree observer is used by default. |
| 56 | #[cfg_attr(feature = "serializing", serde(skip))] |
| 57 | #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_zero_sized)] |
| 58 | pub white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<Wp>, |
| 59 | } |
| 60 | |
| 61 | impl<Wp, T> Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> { |
| 62 | /// Create a CIE L\*C\*h° color. |
| 63 | pub fn newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>>>(l: T, chroma: T, hue: H) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`] { |
| 64 | Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]::new_construst-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new_const().(l, chroma, hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 65 | } |
| 66 | |
| 67 | /// Create a CIE L\*C\*h° color. This is the same as `Lch::new` without the |
| 68 | /// generic hue type. It's temporary until `const fn` supports traits. |
| 69 | pub const fn new_construst-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new_const().(l: T, chroma: T, hue: LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`] { |
| 70 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch# { |
| 71 | lrust-analyzer cargo palette 0.7.6 lch/Lch#l., |
| 72 | chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., |
| 73 | huerust-analyzer cargo palette 0.7.6 lch/Lch#hue., |
| 74 | white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /// Convert to a `(L\*, C\*, h°)` tuple. |
| 79 | pub fn into_componentsrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]into_components().(self) -> (T, T, LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>) { |
| 80 | (self.lrust-analyzer cargo palette 0.7.6 lch/Lch#l., self.chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., self.huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.) |
| 81 | } |
| 82 | |
| 83 | /// Convert from a `(L\*, C\*, h°)` tuple. |
| 84 | pub fn from_componentsrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]from_components().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>>>((l, chroma, hue): (T, T, H)) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`] { |
| 85 | Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().(l, chroma, hue) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | impl<Wp, T> Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 90 | where |
| 91 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Realrust-analyzer cargo palette 0.7.6 num/Real#, |
| 92 | { |
| 93 | /// Return the `l` value minimum. |
| 94 | pub fn min_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_l().() -> T { |
| 95 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 96 | } |
| 97 | |
| 98 | /// Return the `l` value maximum. |
| 99 | pub fn max_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_l().() -> T { |
| 100 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(100.0) |
| 101 | } |
| 102 | |
| 103 | /// Return the `chroma` value minimum. |
| 104 | pub fn min_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_chroma().() -> T { |
| 105 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 106 | } |
| 107 | |
| 108 | /// Return the `chroma` value maximum. This value does not cover the entire |
| 109 | /// color space, but covers enough to be practical for downsampling to |
| 110 | /// smaller color spaces like sRGB. |
| 111 | pub fn max_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_chroma().() -> T { |
| 112 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(128.0) |
| 113 | } |
| 114 | |
| 115 | /// Return the `chroma` extended maximum value. This value covers the entire |
| 116 | /// color space and is included for completeness, but the additional range |
| 117 | /// should be unnecessary for most use cases. |
| 118 | pub fn max_extended_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_extended_chroma().() -> T { |
| 119 | T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(craterust-analyzer cargo palette 0.7.6 crate/::numrust-analyzer cargo palette 0.7.6 num/::Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt#::sqrtrust-analyzer cargo palette 0.7.6 num/impl#[f64][Sqrt]sqrt().(128.0f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().128.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().128.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().128.0)) |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | ///<span id="Lcha"></span>[`Lcha`](crate::Lcha) implementations. |
| 124 | impl<Wp, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T>, A> { |
| 125 | /// Create a CIE L\*C\*h° color with transparency. |
| 126 | pub fn newrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]new().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>>>(l: T, chroma: T, hue: H, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`] { |
| 127 | Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]new_const().(l, chroma, hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), alpha) |
| 128 | } |
| 129 | |
| 130 | /// Create a CIE L\*C\*h° color with transparency. This is the same as |
| 131 | /// `Lcha::new` without the generic hue type. It's temporary until `const |
| 132 | /// fn` supports traits. |
| 133 | pub const fn new_construst-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]new_const().(l: T, chroma: T, hue: LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`] { |
| 134 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# { |
| 135 | colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::new_construst-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new_const().(l, chroma, hue), |
| 136 | alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha., |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /// Convert to a `(L\*, C\*, h°, alpha)` tuple. |
| 141 | pub fn into_componentsrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]into_components().(self) -> (T, T, LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>, A) { |
| 142 | (self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..lrust-analyzer cargo palette 0.7.6 lch/Lch#l., self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..huerust-analyzer cargo palette 0.7.6 lch/Lch#hue., self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.) |
| 143 | } |
| 144 | |
| 145 | /// Convert from a `(L\*, C\*, h°, alpha)` tuple. |
| 146 | pub fn from_componentsrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]from_components().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>>>((l, chroma, hue, alpha): (T, T, H, A)) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`] { |
| 147 | Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]new().(l, chroma, hue, alpha) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | impl_reference_component_methods_huerust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods_hue!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, [lrust-analyzer cargo palette 0.7.6 lch/Lch#l., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma.], white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 152 | impl_struct_of_arrays_methods_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods_hue!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, [l, chroma], white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 153 | |
| 154 | impl<Wp, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T>> for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> { |
| 155 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][`FromColorUnclamped<Self>`]from_color_unclamped().(color: Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T>) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][`FromColorUnclamped<Self>`] { |
| 156 | color |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | impl<Wp, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Labrust-analyzer cargo palette 0.7.6 lab/Lab#<Wp, T>> for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 161 | where |
| 162 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Hypotrust-analyzer cargo palette 0.7.6 num/Hypot#, |
| 163 | Labrust-analyzer cargo palette 0.7.6 lab/Lab#<Wp, T>: GetHuerust-analyzer cargo palette 0.7.6 GetHue#<Huerust-analyzer cargo palette 0.7.6 GetHue#Hue# = LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>>, |
| 164 | { |
| 165 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][`FromColorUnclamped<Lab<Wp, T>>`]from_color_unclamped().(color: Labrust-analyzer cargo palette 0.7.6 lab/Lab#<Wp, T>) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][`FromColorUnclamped<Lab<Wp, T>>`] { |
| 166 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch# { |
| 167 | huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.: color.get_huerust-analyzer cargo palette 0.7.6 GetHue#get_hue().(), |
| 168 | lrust-analyzer cargo palette 0.7.6 lch/Lch#l.: color.lrust-analyzer cargo palette 0.7.6 lab/Lab#l., |
| 169 | chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma.: color.arust-analyzer cargo palette 0.7.6 lab/Lab#a..hypotrust-analyzer cargo palette 0.7.6 num/Hypot#hypot().(color.brust-analyzer cargo palette 0.7.6 lab/Lab#b.), |
| 170 | white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | impl_tuple_conversion_huerust-analyzer cargo palette 0.7.6 macros/convert/impl_tuple_conversion_hue!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp> as (T, T, H), LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#); |
| 176 | |
| 177 | impl_is_within_boundsrust-analyzer cargo palette 0.7.6 macros/clamp/impl_is_within_bounds!! { |
| 178 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp> { |
| 179 | lrust-analyzer cargo palette 0.7.6 lch/Lch#l. => [Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][IsWithinBounds]::min_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_l().(), Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][IsWithinBounds]::max_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_l().()], |
| 180 | chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma. => [Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][IsWithinBounds]::min_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_chroma().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#] |
| 181 | } |
| 182 | where T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 183 | } |
| 184 | impl_clamprust-analyzer cargo palette 0.7.6 macros/clamp/impl_clamp!! { |
| 185 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp> { |
| 186 | lrust-analyzer cargo palette 0.7.6 lch/Lch#l. => [Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ClampAssign]::min_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_l().(), Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ClampAssign]::max_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_l().()], |
| 187 | chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma. => [Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ClampAssign]::min_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_chroma().()] |
| 188 | } |
| 189 | other {huerust-analyzer cargo palette 0.7.6 lch/Lch#hue., white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.} |
| 190 | where T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 191 | } |
| 192 | |
| 193 | impl_mix_huerust-analyzer cargo palette 0.7.6 macros/mix/impl_mix_hue!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp> {l, chroma} phantom: white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 194 | impl_lightenrust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_lighten!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp> increase {l => [Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Lighten]::min_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_l().(), Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Lighten]::max_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_l().()]} other {huerust-analyzer cargo palette 0.7.6 lch/Lch#hue., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma.} phantom: white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 195 | impl_saturaterust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_saturate!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp> increase {chroma => [Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Saturate]::min_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_chroma().(), Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Saturate]::max_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_chroma().()]} other {huerust-analyzer cargo palette 0.7.6 lch/Lch#hue., lrust-analyzer cargo palette 0.7.6 lch/Lch#l.} phantom: white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 196 | impl_hue_opsrust-analyzer cargo palette 0.7.6 macros/hue/impl_hue_ops!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#); |
| 197 | |
| 198 | impl<Wp, T> DeltaErust-analyzer cargo palette 0.7.6 color_difference/DeltaE# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 199 | where |
| 200 | Labrust-analyzer cargo palette 0.7.6 lab/Lab#<Wp, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]> + DeltaErust-analyzer cargo palette 0.7.6 color_difference/DeltaE#<Scalarrust-analyzer cargo palette 0.7.6 color_difference/DeltaE#Scalar# = T>, |
| 201 | { |
| 202 | type Scalarrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]Scalar# = T; |
| 203 | |
| 204 | #[inline] |
| 205 | fn delta_erust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]delta_e().(self, other: Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]::Scalarrust-analyzer cargo palette 0.7.6 color_difference/DeltaE#Scalar# { |
| 206 | // The definitions of delta E for Lch and Lab are equivalent. Converting |
| 207 | // to Lab is the fastest way, so far. |
| 208 | Labrust-analyzer cargo palette 0.7.6 lab/Lab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(self).delta_erust-analyzer cargo palette 0.7.6 color_difference/DeltaE#delta_e().(other.into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/impl#[T][`IntoColorUnclamped<U>`]into_color_unclamped().()) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | impl<Wp, T> ImprovedDeltaErust-analyzer cargo palette 0.7.6 color_difference/ImprovedDeltaE# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 213 | where |
| 214 | Labrust-analyzer cargo palette 0.7.6 lab/Lab#<Wp, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ImprovedDeltaE]> + ImprovedDeltaErust-analyzer cargo palette 0.7.6 color_difference/ImprovedDeltaE#<Scalarrust-analyzer cargo palette 0.7.6 color_difference/DeltaE#Scalar# = T>, |
| 215 | { |
| 216 | #[inline] |
| 217 | fn improved_delta_erust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ImprovedDeltaE]improved_delta_e().(self, other: Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ImprovedDeltaE]) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ImprovedDeltaE]::Scalarrust-analyzer cargo palette 0.7.6 color_difference/DeltaE#Scalar# { |
| 218 | // The definitions of delta E for Lch and Lab are equivalent. |
| 219 | Labrust-analyzer cargo palette 0.7.6 lab/Lab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(self).improved_delta_erust-analyzer cargo palette 0.7.6 color_difference/ImprovedDeltaE#improved_delta_e().(other.into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/impl#[T][`IntoColorUnclamped<U>`]into_color_unclamped().()) |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | /// CIEDE2000 distance metric for color difference. |
| 224 | #[allow(deprecated)] |
| 225 | impl<Wp, T> craterust-analyzer cargo palette 0.7.6 crate/::ColorDifferencerust-analyzer cargo palette 0.7.6 color_difference/ColorDifference# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 226 | where |
| 227 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# |
| 228 | + RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# |
| 229 | + Onerust-analyzer cargo palette 0.7.6 num/One# |
| 230 | + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 231 | + Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry# |
| 232 | + Absrust-analyzer cargo palette 0.7.6 num/Abs# |
| 233 | + Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt# |
| 234 | + Powirust-analyzer cargo palette 0.7.6 num/Powi# |
| 235 | + Exprust-analyzer cargo palette 0.7.6 num/Exp# |
| 236 | + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# |
| 237 | + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp# |
| 238 | + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 239 | T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T> + BitAndrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#Output# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#> + BitOrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#Output# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#>, |
| 240 | Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ColorDifference]: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LabColorDiffrust-analyzer cargo palette 0.7.6 color_difference/LabColorDiff#<T>>, |
| 241 | { |
| 242 | type Scalarrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ColorDifference]Scalar# = T; |
| 243 | |
| 244 | #[inline] |
| 245 | fn get_color_differencerust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ColorDifference]get_color_difference().(self, other: Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T>) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ColorDifference]::Scalarrust-analyzer cargo palette 0.7.6 color_difference/ColorDifference#Scalar# { |
| 246 | get_ciede2000_differencerust-analyzer cargo palette 0.7.6 color_difference/get_ciede2000_difference().(self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), other.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | impl<Wp, T> Ciede2000rust-analyzer cargo palette 0.7.6 color_difference/Ciede2000# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 251 | where |
| 252 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# |
| 253 | + RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# |
| 254 | + Onerust-analyzer cargo palette 0.7.6 num/One# |
| 255 | + Zerorust-analyzer cargo palette 0.7.6 num/Zero# |
| 256 | + Powirust-analyzer cargo palette 0.7.6 num/Powi# |
| 257 | + Exprust-analyzer cargo palette 0.7.6 num/Exp# |
| 258 | + Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry# |
| 259 | + Absrust-analyzer cargo palette 0.7.6 num/Abs# |
| 260 | + Sqrtrust-analyzer cargo palette 0.7.6 num/Sqrt# |
| 261 | + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# |
| 262 | + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp# |
| 263 | + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 264 | T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T> + BitAndrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#Output# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#> + BitOrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#Output# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#>, |
| 265 | Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Ciede2000]: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<Labrust-analyzer cargo palette 0.7.6 lab/Lab#<Wp, T>>, |
| 266 | { |
| 267 | type Scalarrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Ciede2000]Scalar# = T; |
| 268 | |
| 269 | #[inline] |
| 270 | fn differencerust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Ciede2000]difference().(self, other: Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Ciede2000]) -> Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Ciede2000]::Scalarrust-analyzer cargo palette 0.7.6 color_difference/Ciede2000#Scalar# { |
| 271 | get_ciede2000_differencerust-analyzer cargo palette 0.7.6 color_difference/get_ciede2000_difference().(self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), other.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | impl<Wp, T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 276 | where |
| 277 | T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, |
| 278 | { |
| 279 | type Maskrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#; |
| 280 | } |
| 281 | |
| 282 | impl<Wp, T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 283 | where |
| 284 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Realrust-analyzer cargo palette 0.7.6 num/Real#, |
| 285 | LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#<T>: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 286 | { |
| 287 | fn defaultrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Default]default().() -> Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> { |
| 288 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().(Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Default]::min_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_l().(), Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][Default]::min_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_chroma().(), LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().()) |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | impl_color_addrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_add!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, [lrust-analyzer cargo palette 0.7.6 lch/Lch#l., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.], white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 293 | impl_color_subrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_sub!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, [lrust-analyzer cargo palette 0.7.6 lch/Lch#l., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.], white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 294 | |
| 295 | impl_array_castsrust-analyzer cargo palette 0.7.6 macros/casting/impl_array_casts!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T>, [T; 3]); |
| 296 | impl_simd_array_conversion_huerust-analyzer cargo palette 0.7.6 macros/simd/impl_simd_array_conversion_hue!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, [l, chroma], white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 297 | impl_struct_of_array_traits_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_array_traits_hue!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, LabHueIterrust-analyzer cargo palette 0.7.6 hues/LabHueIter#, [lrust-analyzer cargo palette 0.7.6 lch/Lch#l., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma.], white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 298 | |
| 299 | impl_eq_huerust-analyzer cargo palette 0.7.6 macros/equality/impl_eq_hue!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#, [lrust-analyzer cargo palette 0.7.6 lch/Lch#l., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.]); |
| 300 | impl_copy_clonerust-analyzer cargo palette 0.7.6 macros/copy_clone/impl_copy_clone!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp>, [lrust-analyzer cargo palette 0.7.6 lch/Lch#l., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.], white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.); |
| 301 | |
| 302 | #[allow(deprecated)] |
| 303 | impl<Wp, T> craterust-analyzer cargo palette 0.7.6 crate/::RelativeContrastrust-analyzer cargo palette 0.7.6 relative_contrast/RelativeContrast# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> |
| 304 | where |
| 305 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, |
| 306 | T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>, |
| 307 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T>: FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#<Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][RelativeContrast]>, |
| 308 | { |
| 309 | type Scalarrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][RelativeContrast]Scalar# = T; |
| 310 | |
| 311 | #[inline] |
| 312 | fn get_contrast_ratiorust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][RelativeContrast]get_contrast_ratio().(self, other: Selfrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][RelativeContrast]) -> T { |
| 313 | let xyz1 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(self); |
| 314 | let xyz2 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(other); |
| 315 | |
| 316 | craterust-analyzer cargo palette 0.7.6 crate/::contrast_ratiorust-analyzer cargo palette 0.7.6 relative_contrast/contrast_ratio().(xyz1.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., xyz2.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.) |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | impl_rand_traits_cylinderrust-analyzer cargo palette 0.7.6 macros/random/impl_rand_traits_cylinder!!( |
| 321 | UniformLchrust-analyzer cargo palette 0.7.6 lch/UniformLch#, |
| 322 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp> { |
| 323 | hue: UniformLabHuerust-analyzer cargo palette 0.7.6 hues/UniformLabHue# => LabHuerust-analyzer cargo palette 0.7.6 hues/LabHue#, |
| 324 | height: lrust-analyzer cargo palette 0.7.6 lch/Lch#l. => [|l: T| l *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<Wp, T>::max_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_l().()], |
| 325 | radius: chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma. => [|chroma| chroma *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<Wp, T>::max_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_chroma().()] |
| 326 | } |
| 327 | phantom: white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point.: PhantomData<Wp> |
| 328 | where T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::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#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = T>, |
| 329 | ); |
| 330 | |
| 331 | #[cfg(feature = "bytemuck")] |
| 332 | unsafe impl<Wp, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {} |
| 333 | |
| 334 | #[cfg(feature = "bytemuck")] |
| 335 | unsafe impl<Wp: 'static, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<Wp, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {} |
| 336 | |
| 337 | #[cfg(test)] |
| 338 | mod testrust-analyzer cargo palette 0.7.6 lch/test/ { |
| 339 | use craterust-analyzer cargo palette 0.7.6 crate/::{white_pointrust-analyzer cargo palette 0.7.6 white_point/::D65rust-analyzer cargo palette 0.7.6 white_point/D65#, Lchrust-analyzer cargo palette 0.7.6 lch/Lch#}; |
| 340 | |
| 341 | #[cfg(all(feature = "alloc", feature = "approx"))] |
| 342 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 343 | color_differencerust-analyzer cargo palette 0.7.6 color_difference/::{DeltaErust-analyzer cargo palette 0.7.6 color_difference/DeltaE#, ImprovedDeltaErust-analyzer cargo palette 0.7.6 color_difference/ImprovedDeltaE#}, |
| 344 | convertrust-analyzer cargo palette 0.7.6 convert/::IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#, |
| 345 | Labrust-analyzer cargo palette 0.7.6 lab/Lab#, |
| 346 | }; |
| 347 | |
| 348 | test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#); |
| 349 | |
| 350 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 351 | fn rangesrust-analyzer cargo palette 0.7.6 lch/test/ranges().() { |
| 352 | assert_rangesrust-analyzer cargo palette 0.7.6 macros/clamp/assert_ranges!! { |
| 353 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>; |
| 354 | clamped { |
| 355 | l: 0.0 => 100.0 |
| 356 | } |
| 357 | clamped_min { |
| 358 | chroma: 0.0 => 200.0 |
| 359 | } |
| 360 | unclamped { |
| 361 | hue: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().360.0 => 360.0 |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | raw_pixel_conversion_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_tests!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>: l, chroma, hue); |
| 367 | raw_pixel_conversion_fail_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_fail_tests!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>: l, chroma, hue); |
| 368 | |
| 369 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 370 | fn check_min_max_componentsrust-analyzer cargo palette 0.7.6 lch/test/check_min_max_components().() { |
| 371 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::min_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_l().(), 0.0); |
| 372 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::max_lrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_l().(), 100.0); |
| 373 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::min_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]min_chroma().(), 0.0); |
| 374 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::max_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_chroma().(), 128.0); |
| 375 | |
| 376 | #[cfg(feature = "approx")] |
| 377 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::max_extended_chromarust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]max_extended_chroma().(), 181.01933598375618); |
| 378 | } |
| 379 | |
| 380 | #[cfg(feature = "approx")] |
| 381 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 382 | fn delta_e_large_hue_diffrust-analyzer cargo palette 0.7.6 lch/test/delta_e_large_hue_diff().() { |
| 383 | use craterust-analyzer cargo palette 0.7.6 crate/::color_differencerust-analyzer cargo palette 0.7.6 color_difference/::DeltaErust-analyzer cargo palette 0.7.6 color_difference/DeltaE#; |
| 384 | |
| 385 | let lhs1 = Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().(50.0, 64.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().730.0); |
| 386 | let rhs1 = Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().(50.0, 64.0, 730.0); |
| 387 | |
| 388 | let lhs2 = Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().(50.0, 64.0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().10.0); |
| 389 | let rhs2 = Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().(50.0, 64.0, 10.0); |
| 390 | |
| 391 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!( |
| 392 | lhs1.delta_erust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]delta_e().(rhs1), |
| 393 | lhs2.delta_erust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]delta_e().(rhs2), |
| 394 | epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 0.0000000000001 |
| 395 | ); |
| 396 | } |
| 397 | |
| 398 | // Lab and Lch have the same delta E. |
| 399 | #[cfg(all(feature = "alloc", feature = "approx"))] |
| 400 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 401 | fn lab_delta_e_equalityrust-analyzer cargo palette 0.7.6 lch/test/lab_delta_e_equality().() { |
| 402 | let mut lab_colors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Labrust-analyzer cargo palette 0.7.6 lab/Lab#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 403 | |
| 404 | for l_step in 0i8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5 { |
| 405 | for a_step in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().2i8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3 { |
| 406 | for b_step in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().2i8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3 { |
| 407 | lab_colors.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Labrust-analyzer cargo palette 0.7.6 lab/Lab#::newrust-analyzer cargo palette 0.7.6 lab/impl#[`Lab<Wp, T>`]new().( |
| 408 | l_step as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().25.0, |
| 409 | a_step as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0, |
| 410 | b_step as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0, |
| 411 | )) |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | let lch_colors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<_, _>> = lab_colors.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().().into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/impl#[T][`IntoColorUnclamped<U>`]into_color_unclamped().(); |
| 417 | |
| 418 | for (&lhs_lab, &lhs_lch) in lab_colors.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&lch_colors) { |
| 419 | for (&rhs_lab, &rhs_lch) in lab_colors.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&lch_colors) { |
| 420 | let delta_e_lab = lhs_lab.delta_erust-analyzer cargo palette 0.7.6 lab/impl#[`Lab<Wp, T>`][DeltaE]delta_e().(rhs_lab); |
| 421 | let delta_e_lch = lhs_lch.delta_erust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][DeltaE]delta_e().(rhs_lch); |
| 422 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(delta_e_lab, delta_e_lch, epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 0.0000000000001); |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | // Lab and Lch have the same delta E, so should also have the same improved |
| 428 | // delta E. |
| 429 | #[cfg(all(feature = "alloc", feature = "approx"))] |
| 430 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 431 | fn lab_improved_delta_e_equalityrust-analyzer cargo palette 0.7.6 lch/test/lab_improved_delta_e_equality().() { |
| 432 | let mut lab_colors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Labrust-analyzer cargo palette 0.7.6 lab/Lab#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 433 | |
| 434 | for l_step in 0i8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5 { |
| 435 | for a_step in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().2i8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3 { |
| 436 | for b_step in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().2i8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3 { |
| 437 | lab_colors.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Labrust-analyzer cargo palette 0.7.6 lab/Lab#::newrust-analyzer cargo palette 0.7.6 lab/impl#[`Lab<Wp, T>`]new().( |
| 438 | l_step as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().25.0, |
| 439 | a_step as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0, |
| 440 | b_step as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0, |
| 441 | )) |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | let lch_colors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<_, _>> = lab_colors.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().().into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/impl#[T][`IntoColorUnclamped<U>`]into_color_unclamped().(); |
| 447 | |
| 448 | for (&lhs_lab, &lhs_lch) in lab_colors.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&lch_colors) { |
| 449 | for (&rhs_lab, &rhs_lch) in lab_colors.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&lch_colors) { |
| 450 | let delta_e_lab = lhs_lab.improved_delta_erust-analyzer cargo palette 0.7.6 lab/impl#[`Lab<Wp, T>`][ImprovedDeltaE]improved_delta_e().(rhs_lab); |
| 451 | let delta_e_lch = lhs_lch.improved_delta_erust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`][ImprovedDeltaE]improved_delta_e().(rhs_lch); |
| 452 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(delta_e_lab, delta_e_lch, epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 0.0000000000001); |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!( |
| 458 | Lchrust-analyzer cargo palette 0.7.6 lch/Lch#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>[lrust-analyzer cargo palette 0.7.6 lch/Lch#l., chromarust-analyzer cargo palette 0.7.6 lch/Lch#chroma., huerust-analyzer cargo palette 0.7.6 lch/Lch#hue.] phantom: white_pointrust-analyzer cargo palette 0.7.6 lch/Lch#white_point., |
| 459 | superrust-analyzer cargo palette 0.7.6 lch/::Lcharust-analyzer cargo palette 0.7.6 lch/Lcha#::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4), |
| 460 | superrust-analyzer cargo palette 0.7.6 lch/::Lcharust-analyzer cargo palette 0.7.6 lch/Lcha#::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]new().(0.2, 0.3, 0.4, 0.5), |
| 461 | superrust-analyzer cargo palette 0.7.6 lch/::Lcharust-analyzer cargo palette 0.7.6 lch/Lcha#::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Alpha<Lch<Wp, T>, A>`]new().(0.3, 0.4, 0.5, 0.6) |
| 462 | ); |
| 463 | |
| 464 | #[cfg(feature = "serializing")] |
| 465 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 466 | fn serializerust-analyzer cargo palette 0.7.6 lch/test/serialize().() { |
| 467 | let serialized = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::to_stringrust-analyzer cargo serde_json 1.0.116 ser/to_string().(&Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, 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().(); |
| 468 | |
| 469 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#"{"l":0.3,"chroma":0.8,"hue":0.1}"#); |
| 470 | } |
| 471 | |
| 472 | #[cfg(feature = "serializing")] |
| 473 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 474 | fn deserializerust-analyzer cargo palette 0.7.6 lch/test/deserialize().() { |
| 475 | let deserialized: Lchrust-analyzer cargo palette 0.7.6 lch/Lch# = |
| 476 | ::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,"chroma":0.8,"hue":0.1}"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 477 | |
| 478 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, Lchrust-analyzer cargo palette 0.7.6 lch/Lch#::newrust-analyzer cargo palette 0.7.6 lch/impl#[`Lch<Wp, T>`]new().(0.3, 0.8, 0.1)); |
| 479 | } |
| 480 | |
| 481 | test_uniform_distributionrust-analyzer cargo palette 0.7.6 macros/random/test_uniform_distribution!! { |
| 482 | Lch<D65, f32> as crate::Lab { |
| 483 | l: (0.0, 100.0), |
| 484 | a: (-89.0, 89.0), |
| 485 | b: (-89.0, 89.0), |
| 486 | }, |
| 487 | min: Lch::new(0.0f32, 0.0, 0.0), |
| 488 | max: Lch::new(100.0, 128.0, 360.0) |
| 489 | } |
| 490 | } |