| 1 | //! Types for the CIE 1931 XYZ color space. |
| 2 | |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{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#, 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 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 6 | anglerust-analyzer cargo palette 0.7.6 angle/::{RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#, SignedAnglerust-analyzer cargo palette 0.7.6 angle/SignedAngle#}, |
| 7 | 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#}, |
| 8 | cam16rust-analyzer cargo palette 0.7.6 cam16/::{ |
| 9 | Cam16rust-analyzer cargo palette 0.7.6 cam16/full/Cam16#, Cam16IntoUnclampedrust-analyzer cargo palette 0.7.6 cam16/Cam16IntoUnclamped#, Cam16Jchrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jch/Cam16Jch#, Cam16Jmhrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jmh/Cam16Jmh#, Cam16Jshrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jsh/Cam16Jsh#, Cam16Qchrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_qch/Cam16Qch#, Cam16Qmhrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_qmh/Cam16Qmh#, Cam16Qshrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_qsh/Cam16Qsh#, |
| 10 | FromCam16Unclampedrust-analyzer cargo palette 0.7.6 cam16/FromCam16Unclamped#, WhitePointParameterrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#, |
| 11 | }, |
| 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 | encodingrust-analyzer cargo palette 0.7.6 encoding/::IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#, |
| 14 | lumarust-analyzer cargo palette 0.7.6 luma/::LumaStandardrust-analyzer cargo palette 0.7.6 luma/LumaStandard#, |
| 15 | matrixrust-analyzer cargo palette 0.7.6 matrix/::{matrix_maprust-analyzer cargo palette 0.7.6 matrix/matrix_map()., multiply_rgb_to_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_rgb_to_xyz()., multiply_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz()., rgb_to_xyz_matrixrust-analyzer cargo palette 0.7.6 matrix/rgb_to_xyz_matrix().}, |
| 16 | numrust-analyzer cargo palette 0.7.6 num/::{ |
| 17 | Absrust-analyzer cargo palette 0.7.6 num/Abs#, Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#, IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#, Onerust-analyzer cargo palette 0.7.6 num/One#, PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, Powfrust-analyzer cargo palette 0.7.6 num/Powf#, Powirust-analyzer cargo palette 0.7.6 num/Powi#, Realrust-analyzer cargo palette 0.7.6 num/Real#, Reciprust-analyzer cargo palette 0.7.6 num/Recip#, |
| 18 | Signumrust-analyzer cargo palette 0.7.6 num/Signum#, 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#, |
| 19 | }, |
| 20 | oklabrust-analyzer cargo palette 0.7.6 oklab/, |
| 21 | rgbrust-analyzer cargo palette 0.7.6 rgb/::{Primariesrust-analyzer cargo palette 0.7.6 rgb/Primaries#, 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#}, |
| 22 | stimulusrust-analyzer cargo palette 0.7.6 stimulus/::{Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, StimulusColorrust-analyzer cargo palette 0.7.6 stimulus/StimulusColor#}, |
| 23 | white_pointrust-analyzer cargo palette 0.7.6 white_point/::{Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#, D65rust-analyzer cargo palette 0.7.6 white_point/D65#}, |
| 24 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#, Labrust-analyzer cargo palette 0.7.6 lab/Lab#, Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#, Luvrust-analyzer cargo palette 0.7.6 luv/Luv#, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#, |
| 25 | }; |
| 26 | |
| 27 | /// CIE 1931 XYZ with an alpha component. See the [`Xyza` implementation in |
| 28 | /// `Alpha`](crate::Alpha#Xyza). |
| 29 | pub type Xyzarust-analyzer cargo palette 0.7.6 xyz/Xyza#<Wp = D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T = f32> = Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T>, T>; |
| 30 | |
| 31 | /// The CIE 1931 XYZ color space. |
| 32 | /// |
| 33 | /// XYZ links the perceived colors to their wavelengths and simply makes it |
| 34 | /// possible to describe the way we see colors as numbers. It's often used when |
| 35 | /// converting from one color space to an other, and requires a standard |
| 36 | /// illuminant and a standard observer to be defined. |
| 37 | /// |
| 38 | /// Conversions and operations on this color space depend on the defined white |
| 39 | /// point |
| 40 | #[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:)] |
| 41 | #[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 42 | #[palette( |
| 43 | palette_internal, |
| 44 | white_point = "Wp", |
| 45 | component = "T", |
| 46 | skip_derives(Xyz, Yxy, Luv, Rgb, Lab, Oklab, Luma) |
| 47 | )] |
| 48 | #[repr(C)] |
| 49 | pub struct Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp = D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T = f32> { |
| 50 | /// X is the scale of what can be seen as a response curve for the cone |
| 51 | /// cells in the human eye. Its range depends |
| 52 | /// on the white point and goes from 0.0 to 0.95047 for the default D65. |
| 53 | pub xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x.: T, |
| 54 | |
| 55 | /// Y is the luminance of the color, where 0.0 is black and 1.0 is white. |
| 56 | pub yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.: T, |
| 57 | |
| 58 | /// Z is the scale of what can be seen as the blue stimulation. Its range |
| 59 | /// depends on the white point and goes from 0.0 to 1.08883 for the |
| 60 | /// default D65. |
| 61 | pub zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.: T, |
| 62 | |
| 63 | /// The white point associated with the color's illuminant and observer. |
| 64 | /// D65 for 2 degree observer is used by default. |
| 65 | #[cfg_attr(feature = "serializing", serde(skip))] |
| 66 | #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_zero_sized)] |
| 67 | pub white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<Wp>, |
| 68 | } |
| 69 | |
| 70 | impl<Wp, T> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> { |
| 71 | /// Create a CIE XYZ color. |
| 72 | pub const fn newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(x: T, y: T, z: T) -> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> { |
| 73 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz# { |
| 74 | xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., |
| 75 | yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., |
| 76 | zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z., |
| 77 | white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /// Convert to a `(X, Y, Z)` tuple. |
| 82 | pub fn into_componentsrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]into_components().(self) -> (T, T, T) { |
| 83 | (self.xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., self.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., self.zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.) |
| 84 | } |
| 85 | |
| 86 | /// Convert from a `(X, Y, Z)` tuple. |
| 87 | pub fn from_componentsrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]from_components().((x, y, z): (T, T, T)) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`] { |
| 88 | Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(x, y, z) |
| 89 | } |
| 90 | |
| 91 | /// Changes the reference white point without changing the color value. |
| 92 | /// |
| 93 | /// This function doesn't change the numerical values, and thus the color it |
| 94 | /// represents in an absolute sense. However, the appearance of the color |
| 95 | /// may not be the same when observed with the new white point. The effect |
| 96 | /// would be similar to taking a photo with an incorrect white balance. |
| 97 | /// |
| 98 | /// See [chromatic_adaptation](crate::chromatic_adaptation) for operations |
| 99 | /// that can change the white point while preserving the color's appearance. |
| 100 | #[inline] |
| 101 | pub fn with_white_pointrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]with_white_point().<NewWp>(self) -> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<NewWp, T> { |
| 102 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(self.xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., self.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., self.zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | impl<Wp, T> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 107 | where |
| 108 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero#, |
| 109 | Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T>, |
| 110 | { |
| 111 | /// Return the `x` value minimum. |
| 112 | pub fn min_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_x().() -> T { |
| 113 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 114 | } |
| 115 | |
| 116 | /// Return the `x` value maximum. |
| 117 | pub fn max_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_x().() -> T { |
| 118 | Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x. |
| 119 | } |
| 120 | |
| 121 | /// Return the `y` value minimum. |
| 122 | pub fn min_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_y().() -> T { |
| 123 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 124 | } |
| 125 | |
| 126 | /// Return the `y` value maximum. |
| 127 | pub fn max_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_y().() -> T { |
| 128 | Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y. |
| 129 | } |
| 130 | |
| 131 | /// Return the `z` value minimum. |
| 132 | pub fn min_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_z().() -> T { |
| 133 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 134 | } |
| 135 | |
| 136 | /// Return the `z` value maximum. |
| 137 | pub fn max_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_z().() -> T { |
| 138 | Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z. |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | ///<span id="Xyza"></span>[`Xyza`](crate::Xyza) implementations. |
| 143 | impl<Wp, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T>, A> { |
| 144 | /// Create a CIE XYZ color with transparency. |
| 145 | pub const fn newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]new().(x: T, y: T, z: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`] { |
| 146 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# { |
| 147 | colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(x, y, z), |
| 148 | alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha., |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /// Convert to a `(X, Y, Z, alpha)` tuple. |
| 153 | pub fn into_componentsrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]into_components().(self) -> (T, T, T, A) { |
| 154 | (self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z., self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.) |
| 155 | } |
| 156 | |
| 157 | /// Convert from a `(X, Y, Z, alpha)` tuple. |
| 158 | pub fn from_componentsrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]from_components().((x, y, z, alpha): (T, T, T, A)) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`] { |
| 159 | Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]new().(x, y, z, alpha) |
| 160 | } |
| 161 | |
| 162 | /// Changes the reference white point without changing the color value. |
| 163 | /// |
| 164 | /// This function doesn't change the numerical values, and thus the color it |
| 165 | /// represents in an absolute sense. However, the appearance of the color |
| 166 | /// may not be the same when observed with the new white point. The effect |
| 167 | /// would be similar to taking a photo with an incorrect white balance. |
| 168 | /// |
| 169 | /// See [chromatic_adaptation](crate::chromatic_adaptation) for operations |
| 170 | /// that can change the white point while preserving the color's appearance. |
| 171 | #[inline] |
| 172 | pub fn with_white_pointrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]with_white_point().<NewWp>(self) -> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<NewWp, T>, A> { |
| 173 | Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#::<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<NewWp, T>, A>::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]new().(self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z., self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.) |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | impl_reference_component_methodsrust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 178 | impl_struct_of_arrays_methodsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [x, y, z], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 179 | |
| 180 | impl<Wp, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T>> for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> { |
| 181 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Self>`]from_color_unclamped().(color: Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T>) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Self>`] { |
| 182 | color |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | impl<Wp, T, S> 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 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 187 | where |
| 188 | T: Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#, |
| 189 | T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#: Realrust-analyzer cargo palette 0.7.6 num/Real# |
| 190 | + Reciprust-analyzer cargo palette 0.7.6 num/Recip# |
| 191 | + IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool> |
| 192 | + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# |
| 193 | + FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#<Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar# = T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#> |
| 194 | + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 195 | Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>, |
| 196 | S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#, |
| 197 | S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, T>, |
| 198 | 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# = Wp>, |
| 199 | <S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::Primariesrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#Primaries#: Primariesrust-analyzer cargo palette 0.7.6 rgb/Primaries#<T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>, |
| 200 | Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#<Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>>, |
| 201 | { |
| 202 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Rgb<S, T>>`] { |
| 203 | let transform_matrix = S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#::rgb_to_xyz_matrixrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#rgb_to_xyz_matrix().() |
| 204 | .map_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or_else().(rgb_to_xyz_matrixrust-analyzer cargo palette 0.7.6 matrix/rgb_to_xyz_matrix().::<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>, |matrix| { |
| 205 | matrix_maprust-analyzer cargo palette 0.7.6 matrix/matrix_map().(matrix, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().) |
| 206 | }); |
| 207 | multiply_rgb_to_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_rgb_to_xyz().(transform_matrix, color.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().()) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | impl<Wp, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#<Wp, T>> for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 212 | where |
| 213 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Onerust-analyzer cargo palette 0.7.6 num/One# + IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 214 | T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 215 | { |
| 216 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Yxy<Wp, T>>`]from_color_unclamped().(color: Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#<Wp, T>) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Yxy<Wp, T>>`] { |
| 217 | let Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy# { xrust-analyzer cargo palette 0.7.6 yxy/Yxy#x., yrust-analyzer cargo palette 0.7.6 yxy/Yxy#y., lumarust-analyzer cargo palette 0.7.6 yxy/Yxy#luma., .. } = color; |
| 218 | |
| 219 | // If denominator is zero, NAN or INFINITE leave x and z at the default 0 |
| 220 | let mask = y.is_valid_divisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#is_valid_divisor().(); |
| 221 | let xyz = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz# { |
| 222 | zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.: lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 223 | if mask.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() => (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(). &x -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). &y) /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). &y, |
| 224 | else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 225 | }, |
| 226 | xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x.: lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 227 | if mask => x /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). y, |
| 228 | else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), |
| 229 | }, |
| 230 | yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.: T::onerust-analyzer cargo palette 0.7.6 num/One#one().(), |
| 231 | white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 232 | }; |
| 233 | |
| 234 | xyz rust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`Mul<T>`]mul().*rust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`Mul<T>`]mul(). rust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`Mul<T>`]mul().luma |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | 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 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 239 | where |
| 240 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Reciprust-analyzer cargo palette 0.7.6 num/Recip# + Powirust-analyzer cargo palette 0.7.6 num/Powi# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 241 | T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>, |
| 242 | Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T>, |
| 243 | { |
| 244 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<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 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Lab<Wp, T>>`] { |
| 245 | // Recip call shows performance benefits in benchmarks for this function |
| 246 | let y = (color.lrust-analyzer cargo palette 0.7.6 lab/Lab#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().(16.0)) 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::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(116.0).reciprust-analyzer cargo palette 0.7.6 num/Recip#recip().(); |
| 247 | let x = y.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().(color.arust-analyzer cargo palette 0.7.6 lab/Lab#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().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(500.0).reciprust-analyzer cargo palette 0.7.6 num/Recip#recip().()); |
| 248 | let z = y.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/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().(color.brust-analyzer cargo palette 0.7.6 lab/Lab#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().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(200.0).reciprust-analyzer cargo palette 0.7.6 num/Recip#recip().()); |
| 249 | |
| 250 | let epsilon: T = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().29.0); |
| 251 | let kappa: T = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(108.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().841.0); |
| 252 | let delta: T = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().29.0); |
| 253 | |
| 254 | let convert = |c: T| { |
| 255 | lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! { |
| 256 | if c.gtrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt().(&epsilon) => c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3), |
| 257 | else => (c.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/Sub#sub(). &delta) *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). &kappa |
| 258 | } |
| 259 | }; |
| 260 | |
| 261 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(convert(x), convert(y), convert(z)) rust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`Mul<Self>`]mul().*rust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`Mul<Self>`]mul(). rust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`Mul<Self>`]mul().Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().with_white_pointrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]with_white_point().() |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | impl<Wp, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Luvrust-analyzer cargo palette 0.7.6 luv/Luv#<Wp, T>> for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 266 | where |
| 267 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + Reciprust-analyzer cargo palette 0.7.6 num/Recip# + Powirust-analyzer cargo palette 0.7.6 num/Powi# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool>, |
| 268 | Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T>, |
| 269 | { |
| 270 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Luv<Wp, T>>`]from_color_unclamped().(color: Luvrust-analyzer cargo palette 0.7.6 luv/Luv#<Wp, T>) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Luv<Wp, T>>`] { |
| 271 | let kappa = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(29.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().3.0).powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3); |
| 272 | |
| 273 | let w = Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().(); |
| 274 | let ref_denom_recip = |
| 275 | (w.xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x..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().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(15.0) 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().&w.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y. 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().(3.0) 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().w.zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.).reciprust-analyzer cargo palette 0.7.6 num/Recip#recip().(); |
| 276 | let u_ref = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0) 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().w.xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x. 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().&ref_denom_recip; |
| 277 | let v_ref = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(9.0) 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().&w.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y. 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().ref_denom_recip; |
| 278 | |
| 279 | if color.lrust-analyzer cargo palette 0.7.6 luv/Luv#l. 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().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1e-5) { |
| 280 | return Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, 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().()); |
| 281 | } |
| 282 | |
| 283 | let y = if color.lrust-analyzer cargo palette 0.7.6 luv/Luv#l. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(8.0) { |
| 284 | ((color.lrust-analyzer cargo palette 0.7.6 luv/Luv#l..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().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(16.0)) 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::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(116.0).reciprust-analyzer cargo palette 0.7.6 num/Recip#recip().()).powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3) |
| 285 | } else { |
| 286 | color.lrust-analyzer cargo palette 0.7.6 luv/Luv#l..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().kappa.reciprust-analyzer cargo palette 0.7.6 num/Recip#recip().() |
| 287 | } 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().w.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.; |
| 288 | |
| 289 | let u_prime = color.urust-analyzer cargo palette 0.7.6 luv/Luv#u. 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::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(13.0) 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().&color.lrust-analyzer cargo palette 0.7.6 luv/Luv#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().u_ref; |
| 290 | let v_prime = color.vrust-analyzer cargo palette 0.7.6 luv/Luv#v. 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::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(13.0) 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().color.lrust-analyzer cargo palette 0.7.6 luv/Luv#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().v_ref; |
| 291 | |
| 292 | let x = y.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().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.25) 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().&u_prime 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().&v_prime; |
| 293 | let z = y.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |
| 294 | *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::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0) 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.75) 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().u_prime 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().(5.0) 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().&v_prime) |
| 295 | /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().v_prime; |
| 296 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(x, y, z) |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | 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 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T> |
| 301 | where |
| 302 | T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Powirust-analyzer cargo palette 0.7.6 num/Powi# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, |
| 303 | { |
| 304 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<D65, T>`][`FromColorUnclamped<Oklab<T>>`]from_color_unclamped().(color: Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<D65, T>`][`FromColorUnclamped<Oklab<T>>`] { |
| 305 | let m1_inv = oklabrust-analyzer cargo palette 0.7.6 oklab/::m1_invrust-analyzer cargo palette 0.7.6 oklab/m1_inv().(); |
| 306 | let m2_inv = oklabrust-analyzer cargo palette 0.7.6 oklab/::m2_invrust-analyzer cargo palette 0.7.6 oklab/m2_inv().(); |
| 307 | |
| 308 | let Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz# { |
| 309 | 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, .. |
| 310 | } = multiply_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz().(m2_inv, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(color.lrust-analyzer cargo palette 0.7.6 oklab/Oklab#l., color.arust-analyzer cargo palette 0.7.6 oklab/Oklab#a., color.brust-analyzer cargo palette 0.7.6 oklab/Oklab#b.)); |
| 311 | |
| 312 | let lms = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(l.powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3), m.powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3), s.powirust-analyzer cargo palette 0.7.6 num/Powi#powi().(3)); |
| 313 | multiply_xyzrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz().(m1_inv, lms).with_white_pointrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]with_white_point().() |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | impl<Wp, T, S> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#<S, T>> for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 318 | where |
| 319 | Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Luma<S, T>>`]: Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<T, Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#Output# = Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Luma<S, T>>`]>, |
| 320 | Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T>, |
| 321 | S: LumaStandardrust-analyzer cargo palette 0.7.6 luma/LumaStandard#<WhitePointrust-analyzer cargo palette 0.7.6 luma/LumaStandard#WhitePoint# = Wp>, |
| 322 | S::TransferFnrust-analyzer cargo palette 0.7.6 luma/LumaStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, T>, |
| 323 | { |
| 324 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Luma<S, T>>`]from_color_unclamped().(color: Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][`FromColorUnclamped<Luma<S, T>>`] { |
| 325 | Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().with_white_pointrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]with_white_point().::<Wp>() 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().color.into_linearrust-analyzer cargo palette 0.7.6 luma/luma/impl#[`Luma<S, T>`]into_linear().().lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#luma. |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | impl<WpParam, T> FromCam16Unclampedrust-analyzer cargo palette 0.7.6 cam16/FromCam16Unclamped#<WpParam, Cam16rust-analyzer cargo palette 0.7.6 cam16/full/Cam16#<T>> for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<WpParam::StaticWprust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#StaticWp#, T> |
| 330 | where |
| 331 | WpParam: WhitePointParameterrust-analyzer cargo palette 0.7.6 cam16/parameters/WhitePointParameter#<T>, |
| 332 | T: FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#, |
| 333 | Cam16Jchrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jch/Cam16Jch#<T>: Cam16IntoUnclampedrust-analyzer cargo palette 0.7.6 cam16/Cam16IntoUnclamped#<WpParam, Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>`][`FromCam16Unclamped<WpParam, Cam16<T>>`], Scalarrust-analyzer cargo palette 0.7.6 cam16/Cam16IntoUnclamped#Scalar# = T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>, |
| 334 | { |
| 335 | type Scalarrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>`][`FromCam16Unclamped<WpParam, Cam16<T>>`]Scalar# = T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#; |
| 336 | |
| 337 | fn from_cam16_unclampedrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>`][`FromCam16Unclamped<WpParam, Cam16<T>>`]from_cam16_unclamped().( |
| 338 | cam16: Cam16rust-analyzer cargo palette 0.7.6 cam16/full/Cam16#<T>, |
| 339 | parameters: craterust-analyzer cargo palette 0.7.6 crate/::cam16rust-analyzer cargo palette 0.7.6 cam16/::BakedParametersrust-analyzer cargo palette 0.7.6 cam16/parameters/BakedParameters#<WpParam, Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>`][`FromCam16Unclamped<WpParam, Cam16<T>>`]::Scalarrust-analyzer cargo palette 0.7.6 cam16/FromCam16Unclamped#Scalar#>, |
| 340 | ) -> Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>`][`FromCam16Unclamped<WpParam, Cam16<T>>`] { |
| 341 | Cam16Jchrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jch/Cam16Jch#::fromrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jch/impl#[`Cam16Jch<T>`][`From<Cam16<T>>`]from().(cam16).cam16_into_unclampedrust-analyzer cargo palette 0.7.6 cam16/Cam16IntoUnclamped#cam16_into_unclamped().(parameters) |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | macro_rules! impl_from_cam16_partialrust-analyzer cargo palette 0.7.6 xyz/impl_from_cam16_partial! { |
| 346 | ($($name: ident),+) => { |
| 347 | $( |
| 348 | impl<WpParam, T> FromCam16Unclamped<WpParam, $name<T>> for Xyz<WpParam::StaticWp, T> |
| 349 | where |
| 350 | WpParam: WhitePointParameter<T>, |
| 351 | T: Real |
| 352 | + FromScalar |
| 353 | + One |
| 354 | + Zero |
| 355 | + Sqrt |
| 356 | + Powf |
| 357 | + Abs |
| 358 | + Signum |
| 359 | + Arithmetics |
| 360 | + Trigonometry |
| 361 | + RealAngle |
| 362 | + SignedAngle |
| 363 | + PartialCmp |
| 364 | + Clone, |
| 365 | T::Mask: LazySelect<T> + Clone, |
| 366 | T::Scalar: Clone, |
| 367 | { |
| 368 | type Scalar = T::Scalar; |
| 369 | |
| 370 | fn from_cam16_unclamped( |
| 371 | cam16: $name<T>, |
| 372 | parameters: crate::cam16::BakedParameters<WpParam, Self::Scalar>, |
| 373 | ) -> Self { |
| 374 | crate::cam16::math::cam16_to_xyz(cam16.into_dynamic(), parameters.inner) |
| 375 | .with_white_point() |
| 376 | } |
| 377 | } |
| 378 | )+ |
| 379 | }; |
| 380 | } |
| 381 | |
| 382 | impl_from_cam16_partialrust-analyzer cargo palette 0.7.6 xyz/impl_from_cam16_partial!!(Cam16Jmhrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jmh/Cam16Jmh#, Cam16Jchrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jch/Cam16Jch#, Cam16Jshrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_jsh/Cam16Jsh#, Cam16Qmhrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_qmh/Cam16Qmh#, Cam16Qchrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_qch/Cam16Qch#, Cam16Qshrust-analyzer cargo palette 0.7.6 cam16/partial/cam16_qsh/Cam16Qsh#); |
| 383 | |
| 384 | impl_tuple_conversionrust-analyzer cargo palette 0.7.6 macros/convert/impl_tuple_conversion!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp> as (T, T, T)); |
| 385 | |
| 386 | impl_is_within_boundsrust-analyzer cargo palette 0.7.6 macros/clamp/impl_is_within_bounds!! { |
| 387 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp> { |
| 388 | xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x. => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][IsWithinBounds]::min_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_x().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][IsWithinBounds]::max_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_x().()], |
| 389 | yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y. => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][IsWithinBounds]::min_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_y().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][IsWithinBounds]::max_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_y().()], |
| 390 | zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z. => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][IsWithinBounds]::min_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_z().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][IsWithinBounds]::max_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_z().()] |
| 391 | } |
| 392 | where |
| 393 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero#, |
| 394 | Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T> |
| 395 | } |
| 396 | impl_clamprust-analyzer cargo palette 0.7.6 macros/clamp/impl_clamp!! { |
| 397 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp> { |
| 398 | xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x. => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][ClampAssign]::min_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_x().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][ClampAssign]::max_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_x().()], |
| 399 | yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y. => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][ClampAssign]::min_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_y().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][ClampAssign]::max_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_y().()], |
| 400 | zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z. => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][ClampAssign]::min_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_z().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][ClampAssign]::max_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_z().()] |
| 401 | } |
| 402 | other {white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.} |
| 403 | where |
| 404 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero#, |
| 405 | Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T> |
| 406 | } |
| 407 | |
| 408 | impl_mixrust-analyzer cargo palette 0.7.6 macros/mix/impl_mix!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>); |
| 409 | impl_lightenrust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_lighten!! { |
| 410 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp> |
| 411 | increase { |
| 412 | x => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][Lighten]::min_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_x().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][Lighten]::max_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_x().()], |
| 413 | y => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][Lighten]::min_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_y().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][Lighten]::max_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_y().()], |
| 414 | z => [Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][Lighten]::min_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_z().(), Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][Lighten]::max_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_z().()] |
| 415 | } |
| 416 | other {} |
| 417 | phantom: white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point. |
| 418 | where Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T> |
| 419 | } |
| 420 | impl_premultiplyrust-analyzer cargo palette 0.7.6 macros/blend/impl_premultiply!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp> {xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.} phantom: white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 421 | impl_euclidean_distancerust-analyzer cargo palette 0.7.6 macros/color_difference/impl_euclidean_distance!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp> {xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.}); |
| 422 | |
| 423 | impl<Wp, T> StimulusColorrust-analyzer cargo palette 0.7.6 stimulus/StimulusColor# for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus# {} |
| 424 | |
| 425 | impl<Wp, T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 426 | where |
| 427 | T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, |
| 428 | { |
| 429 | type Maskrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#; |
| 430 | } |
| 431 | |
| 432 | impl<Wp, T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 433 | where |
| 434 | T: Zerorust-analyzer cargo palette 0.7.6 num/Zero#, |
| 435 | { |
| 436 | fn defaultrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][Default]default().() -> Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> { |
| 437 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, 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().()) |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | impl_color_addrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_add!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 442 | impl_color_subrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_sub!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 443 | impl_color_mulrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_mul!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 444 | impl_color_divrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_div!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 445 | |
| 446 | impl_array_castsrust-analyzer cargo palette 0.7.6 macros/casting/impl_array_casts!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T>, [T; 3]); |
| 447 | impl_simd_array_conversionrust-analyzer cargo palette 0.7.6 macros/simd/impl_simd_array_conversion!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [x, y, z], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 448 | impl_struct_of_array_traitsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_array_traits!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 449 | |
| 450 | impl_copy_clonerust-analyzer cargo palette 0.7.6 macros/copy_clone/impl_copy_clone!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.], white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.); |
| 451 | impl_eqrust-analyzer cargo palette 0.7.6 macros/equality/impl_eq!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp>, [xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.]); |
| 452 | |
| 453 | #[allow(deprecated)] |
| 454 | impl<Wp, T> craterust-analyzer cargo palette 0.7.6 crate/::RelativeContrastrust-analyzer cargo palette 0.7.6 relative_contrast/RelativeContrast# for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> |
| 455 | where |
| 456 | 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#, |
| 457 | T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>, |
| 458 | { |
| 459 | type Scalarrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][RelativeContrast]Scalar# = T; |
| 460 | |
| 461 | #[inline] |
| 462 | fn get_contrast_ratiorust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][RelativeContrast]get_contrast_ratio().(self, other: Selfrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`][RelativeContrast]) -> T { |
| 463 | craterust-analyzer cargo palette 0.7.6 crate/::contrast_ratiorust-analyzer cargo palette 0.7.6 relative_contrast/contrast_ratio().(self.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., other.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.) |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | impl_rand_traits_cartesianrust-analyzer cargo palette 0.7.6 macros/random/impl_rand_traits_cartesian!!( |
| 468 | UniformXyzrust-analyzer cargo palette 0.7.6 xyz/UniformXyz#, |
| 469 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp> { |
| 470 | xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x. => [|x| x *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x.], |
| 471 | yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y. => [|y| y *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.], |
| 472 | zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z. => [|z| z *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). Wp::get_xyzrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#get_xyz().().zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.] |
| 473 | } |
| 474 | phantom: white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point.: PhantomData<Wp> |
| 475 | where T: 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>, Wp: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T> |
| 476 | ); |
| 477 | |
| 478 | #[cfg(feature = "bytemuck")] |
| 479 | unsafe impl<Wp, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {} |
| 480 | |
| 481 | #[cfg(feature = "bytemuck")] |
| 482 | unsafe impl<Wp: 'static, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Wp, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {} |
| 483 | |
| 484 | #[cfg(test)] |
| 485 | mod testrust-analyzer cargo palette 0.7.6 xyz/test/ { |
| 486 | use superrust-analyzer cargo palette 0.7.6 xyz/::Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#; |
| 487 | 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#; |
| 488 | |
| 489 | #[cfg(feature = "random")] |
| 490 | use craterust-analyzer cargo palette 0.7.6 crate/::white_pointrust-analyzer cargo palette 0.7.6 white_point/::WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#; |
| 491 | |
| 492 | const X_Nrust-analyzer cargo palette 0.7.6 xyz/test/X_N.: f64 = 0.95047; |
| 493 | const Y_Nrust-analyzer cargo palette 0.7.6 xyz/test/Y_N.: f64 = 1.0; |
| 494 | const Z_Nrust-analyzer cargo palette 0.7.6 xyz/test/Z_N.: f64 = 1.08883; |
| 495 | |
| 496 | test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#); |
| 497 | |
| 498 | #[cfg(feature = "approx")] |
| 499 | mod conversionrust-analyzer cargo palette 0.7.6 xyz/test/conversion/ { |
| 500 | 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#, FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, LinLumarust-analyzer cargo palette 0.7.6 luma/LinLuma#, LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#}; |
| 501 | |
| 502 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 503 | fn lumarust-analyzer cargo palette 0.7.6 xyz/test/conversion/luma().() { |
| 504 | let a = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(LinLumarust-analyzer cargo palette 0.7.6 luma/LinLuma#::newrust-analyzer cargo palette 0.7.6 luma/luma/impl#[`Luma<S, T>`]new().(0.5)); |
| 505 | let b = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(0.475235, 0.5, 0.544415); |
| 506 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b, epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 0.0001); |
| 507 | } |
| 508 | |
| 509 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 510 | fn redrust-analyzer cargo palette 0.7.6 xyz/test/conversion/red().() { |
| 511 | let a = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::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)); |
| 512 | let b = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(0.41240, 0.21260, 0.01930); |
| 513 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b, epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 0.0001); |
| 514 | } |
| 515 | |
| 516 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 517 | fn greenrust-analyzer cargo palette 0.7.6 xyz/test/conversion/green().() { |
| 518 | let a = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::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)); |
| 519 | let b = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(0.35760, 0.71520, 0.11920); |
| 520 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b, epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 0.0001); |
| 521 | } |
| 522 | |
| 523 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 524 | fn bluerust-analyzer cargo palette 0.7.6 xyz/test/conversion/blue().() { |
| 525 | let a = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::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)); |
| 526 | let b = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(0.18050, 0.07220, 0.95030); |
| 527 | assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b, epsilonrust-analyzer cargo approx 0.5.1 impl#[`Relative<A, B>`]epsilon(). = 0.0001); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 532 | fn rangesrust-analyzer cargo palette 0.7.6 xyz/test/ranges().() { |
| 533 | assert_rangesrust-analyzer cargo palette 0.7.6 macros/clamp/assert_ranges!! { |
| 534 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>; |
| 535 | clamped { |
| 536 | x: 0.0 => X_Nrust-analyzer cargo palette 0.7.6 xyz/test/X_N., |
| 537 | y: 0.0 => Y_Nrust-analyzer cargo palette 0.7.6 xyz/test/Y_N., |
| 538 | z: 0.0 => Z_Nrust-analyzer cargo palette 0.7.6 xyz/test/Z_N. |
| 539 | } |
| 540 | clamped_min {} |
| 541 | unclamped {} |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | raw_pixel_conversion_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_tests!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>: x, y, z); |
| 546 | raw_pixel_conversion_fail_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_fail_tests!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>: x, y, z); |
| 547 | |
| 548 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 549 | fn check_min_max_componentsrust-analyzer cargo palette 0.7.6 xyz/test/check_min_max_components().() { |
| 550 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>::min_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_x().(), 0.0); |
| 551 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>::min_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_y().(), 0.0); |
| 552 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>::min_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]min_z().(), 0.0); |
| 553 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::max_xrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_x().(), X_Nrust-analyzer cargo palette 0.7.6 xyz/test/X_N.); |
| 554 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::max_yrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_y().(), Y_Nrust-analyzer cargo palette 0.7.6 xyz/test/Y_N.); |
| 555 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, f64>::max_zrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]max_z().(), Z_Nrust-analyzer cargo palette 0.7.6 xyz/test/Z_N.); |
| 556 | } |
| 557 | |
| 558 | struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!( |
| 559 | Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>[xrust-analyzer cargo palette 0.7.6 xyz/Xyz#x., yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., zrust-analyzer cargo palette 0.7.6 xyz/Xyz#z.] phantom: white_pointrust-analyzer cargo palette 0.7.6 xyz/Xyz#white_point., |
| 560 | superrust-analyzer cargo palette 0.7.6 xyz/::Xyzarust-analyzer cargo palette 0.7.6 xyz/Xyza#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4), |
| 561 | superrust-analyzer cargo palette 0.7.6 xyz/::Xyzarust-analyzer cargo palette 0.7.6 xyz/Xyza#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]new().(0.2, 0.3, 0.4, 0.5), |
| 562 | superrust-analyzer cargo palette 0.7.6 xyz/::Xyzarust-analyzer cargo palette 0.7.6 xyz/Xyza#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Alpha<Xyz<Wp, T>, A>`]new().(0.3, 0.4, 0.5, 0.6) |
| 563 | ); |
| 564 | |
| 565 | #[cfg(feature = "serializing")] |
| 566 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 567 | fn serializerust-analyzer cargo palette 0.7.6 xyz/test/serialize().() { |
| 568 | let serialized = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::to_stringrust-analyzer cargo serde_json 1.0.116 ser/to_string().(&Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<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().(); |
| 569 | |
| 570 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#"{"x":0.3,"y":0.8,"z":0.1}"#); |
| 571 | } |
| 572 | |
| 573 | #[cfg(feature = "serializing")] |
| 574 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 575 | fn deserializerust-analyzer cargo palette 0.7.6 xyz/test/deserialize().() { |
| 576 | let deserialized: Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz# = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::from_strrust-analyzer cargo serde_json 1.0.116 de/from_str().(r#"{"x":0.3,"y":0.8,"z":0.1}"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 577 | |
| 578 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::newrust-analyzer cargo palette 0.7.6 xyz/impl#[`Xyz<Wp, T>`]new().(0.3, 0.8, 0.1)); |
| 579 | } |
| 580 | |
| 581 | test_uniform_distributionrust-analyzer cargo palette 0.7.6 macros/random/test_uniform_distribution!! { |
| 582 | Xyz<D65, f32> { |
| 583 | x: (0.0, D65::get_xyz().x), |
| 584 | y: (0.0, D65::get_xyz().y), |
| 585 | z: (0.0, D65::get_xyz().z) |
| 586 | }, |
| 587 | min: Xyz::new(0.0f32, 0.0, 0.0), |
| 588 | max: D65::get_xyz().with_white_point() |
| 589 | } |
| 590 | } |