| 1 | //! Types for the Okhwb color space. |
| 2 | |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#; |
| 4 | |
| 5 | pub use alpharust-analyzer cargo palette 0.7.6 okhwb/alpha/::Okhwbarust-analyzer cargo palette 0.7.6 okhwb/alpha/Okhwba#; |
| 6 | |
| 7 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 8 | anglerust-analyzer cargo palette 0.7.6 angle/::FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#, |
| 9 | convertrust-analyzer cargo palette 0.7.6 convert/::FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#, |
| 10 | numrust-analyzer cargo palette 0.7.6 num/::{Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, Onerust-analyzer cargo palette 0.7.6 num/One#}, |
| 11 | stimulusrust-analyzer cargo palette 0.7.6 stimulus/::{FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#, Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#}, |
| 12 | white_pointrust-analyzer cargo palette 0.7.6 white_point/::D65rust-analyzer cargo palette 0.7.6 white_point/D65#, |
| 13 | HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#, OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#, |
| 14 | }; |
| 15 | |
| 16 | pub use selfrust-analyzer cargo palette 0.7.6 okhwb/::propertiesrust-analyzer cargo palette 0.7.6 okhwb/properties/::Iterrust-analyzer cargo palette 0.7.6 okhwb/properties/Iter#; |
| 17 | |
| 18 | #[cfg(feature = "random")] |
| 19 | pub use selfrust-analyzer cargo palette 0.7.6 okhwb/::randomrust-analyzer cargo palette 0.7.6 okhwb/random/::UniformOkhwbrust-analyzer cargo palette 0.7.6 okhwb/random/UniformOkhwb#; |
| 20 | |
| 21 | mod alpharust-analyzer cargo palette 0.7.6 okhwb/alpha/; |
| 22 | mod propertiesrust-analyzer cargo palette 0.7.6 okhwb/properties/; |
| 23 | #[cfg(feature = "random")] |
| 24 | mod randomrust-analyzer cargo palette 0.7.6 okhwb/random/; |
| 25 | #[cfg(test)] |
| 26 | #[cfg(feature = "approx")] |
| 27 | mod visual_eqrust-analyzer cargo palette 0.7.6 okhwb/visual_eq/; |
| 28 | |
| 29 | /// A Hue/Whiteness/Blackness representation of [`Oklab`][crate::Oklab] in the |
| 30 | /// `sRGB` color space, similar to [`Hwb`][crate::Okhwb]. |
| 31 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, ArrayCastrust-analyzer cargo palette_derive 0.7.6 ArrayCast:, FromColorUnclampedrust-analyzer cargo palette_derive 0.7.6 FromColorUnclamped:, WithAlpharust-analyzer cargo palette_derive 0.7.6 WithAlpha:)] |
| 32 | #[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 33 | #[palette( |
| 34 | palette_internal, |
| 35 | white_point = "D65", |
| 36 | component = "T", |
| 37 | skip_derives(Okhwb, Okhsv) |
| 38 | )] |
| 39 | #[repr(C)] |
| 40 | pub struct Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T = f32> { |
| 41 | /// The hue of the color, in degrees of a circle. |
| 42 | /// |
| 43 | /// For fully saturated, bright colors |
| 44 | /// * 0° corresponds to a kind of magenta-pink (RBG #ff0188), |
| 45 | /// * 90° to a kind of yellow (RBG RGB #ffcb00) |
| 46 | /// * 180° to a kind of cyan (RBG #00ffe1) and |
| 47 | /// * 240° to a kind of blue (RBG #00aefe). |
| 48 | /// |
| 49 | /// For s == 0 or v == 0, the hue is irrelevant. |
| 50 | #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_same_layout_as = "T")] |
| 51 | pub huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue.: OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>, |
| 52 | |
| 53 | /// The amount of white, mixed in the pure hue, ranging from `0.0` to `1.0`. |
| 54 | /// `0.0` produces pure, possibly black color. `1.0` a white or grey. |
| 55 | pub whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness.: T, |
| 56 | |
| 57 | /// The amount of black, mixed in the pure hue, ranging from `0.0` to `1.0`. |
| 58 | /// `0.0` produces a pure bright or whitened color. `1.0` a black or grey. |
| 59 | pub blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness.: T, |
| 60 | } |
| 61 | |
| 62 | impl<T> Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> { |
| 63 | /// Create an `Okhwb` color. |
| 64 | pub fn newrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]new().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>>>(hue: H, whiteness: T, blackness: T) -> Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`] { |
| 65 | let hue = hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 66 | Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`] { |
| 67 | huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue., |
| 68 | whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness., |
| 69 | blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness., |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /// Create an `Okhwb` color. This is the same as `Okhwb::new` without the |
| 74 | /// generic hue type. It's temporary until `const fn` supports traits. |
| 75 | pub const fn new_construst-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]new_const().(hue: OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>, whiteness: T, blackness: T) -> Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`] { |
| 76 | Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`] { |
| 77 | huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue., |
| 78 | whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness., |
| 79 | blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness., |
| 80 | } |
| 81 | } |
| 82 | /// Convert into another component type. |
| 83 | pub fn into_formatrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]into_format().<U>(self) -> Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<U> |
| 84 | where |
| 85 | U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<T>, |
| 86 | { |
| 87 | Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb# { |
| 88 | huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue.: self.huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue..into_formatrust-analyzer cargo palette 0.7.6 hues/impl#[`OklabHue<T>`]into_format().(), |
| 89 | whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness.), |
| 90 | blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness.), |
| 91 | } |
| 92 | } |
| 93 | /// Convert to a `(h, w, b)` tuple. |
| 94 | pub fn into_componentsrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]into_components().(self) -> (OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>, T, T) { |
| 95 | (self.huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue., self.whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness., self.blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness.) |
| 96 | } |
| 97 | |
| 98 | /// Convert from a `(h, w, b)` tuple. |
| 99 | pub fn from_componentsrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]from_components().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>>>((hue, whiteness, blackness): (H, T, T)) -> Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`] { |
| 100 | Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]::newrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]new().(hue, whiteness, blackness) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | impl<T> Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> |
| 105 | where |
| 106 | T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 107 | { |
| 108 | /// Return the `whiteness` value minimum. |
| 109 | pub fn min_whitenessrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]min_whiteness().() -> T { |
| 110 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 111 | } |
| 112 | |
| 113 | /// Return the `whiteness` value maximum. |
| 114 | pub fn max_whitenessrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]max_whiteness().() -> T { |
| 115 | T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().() |
| 116 | } |
| 117 | |
| 118 | /// Return the `blackness` value minimum. |
| 119 | pub fn min_blacknessrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]min_blackness().() -> T { |
| 120 | T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().() |
| 121 | } |
| 122 | |
| 123 | /// Return the `blackness` value maximum. |
| 124 | pub fn max_blacknessrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]max_blackness().() -> T { |
| 125 | T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().() |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | impl_reference_component_methods_huerust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods_hue!!(Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#, [whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness.]); |
| 130 | impl_struct_of_arrays_methods_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods_hue!!(Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#, [whiteness, blackness]); |
| 131 | |
| 132 | impl<T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#<T>> for Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> |
| 133 | where |
| 134 | T: Onerust-analyzer cargo palette 0.7.6 num/One# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, |
| 135 | { |
| 136 | /// Converts `lab` to `Okhwb` in the bounds of sRGB. |
| 137 | fn from_color_unclampedrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][`FromColorUnclamped<Okhsv<T>>`]from_color_unclamped().(hsv: Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#<T>) -> Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][`FromColorUnclamped<Okhsv<T>>`] { |
| 138 | // See <https://bottosson.github.io/posts/colorpicker/#okhwb>. |
| 139 | Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][`FromColorUnclamped<Okhsv<T>>`] { |
| 140 | huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue.: hsv.huerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#hue., |
| 141 | whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness.: (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().hsv.saturationrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#saturation.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().&hsv.valuerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#value., |
| 142 | blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness.: T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().hsv.valuerust-analyzer cargo palette 0.7.6 okhsv/Okhsv#value., |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | impl<T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> |
| 148 | where |
| 149 | T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, |
| 150 | { |
| 151 | type Maskrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#; |
| 152 | } |
| 153 | |
| 154 | impl<T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> |
| 155 | where |
| 156 | T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, |
| 157 | OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#<T>: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 158 | { |
| 159 | fn defaultrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][Default]default().() -> Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> { |
| 160 | Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#::newrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]new().( |
| 161 | OklabHuerust-analyzer cargo palette 0.7.6 hues/OklabHue#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().(), |
| 162 | Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][Default]::min_whitenessrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]min_whiteness().(), |
| 163 | Selfrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][Default]::max_blacknessrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`]max_blackness().(), |
| 164 | ) |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | #[cfg(feature = "bytemuck")] |
| 169 | unsafe impl<T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {} |
| 170 | |
| 171 | #[cfg(feature = "bytemuck")] |
| 172 | unsafe impl<T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#<T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {} |
| 173 | |
| 174 | #[cfg(test)] |
| 175 | mod testsrust-analyzer cargo palette 0.7.6 okhwb/tests/ { |
| 176 | use craterust-analyzer cargo palette 0.7.6 crate/::Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#; |
| 177 | |
| 178 | test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#); |
| 179 | |
| 180 | #[cfg(feature = "approx")] |
| 181 | mod conversionrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/ { |
| 182 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 183 | convertrust-analyzer cargo palette 0.7.6 convert/::FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#, encodingrust-analyzer cargo palette 0.7.6 encoding/, rgbrust-analyzer cargo palette 0.7.6 rgb/::Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#, visualrust-analyzer cargo palette 0.7.6 visual/::VisuallyEqualrust-analyzer cargo palette 0.7.6 visual/VisuallyEqual#, LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#, Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#, |
| 184 | Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, |
| 185 | }; |
| 186 | |
| 187 | #[cfg_attr(miri, ignore)] |
| 188 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 189 | fn test_roundtrip_okhwb_oklab_is_originalrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/test_roundtrip_okhwb_oklab_is_original().() { |
| 190 | let colors = [ |
| 191 | ( |
| 192 | "red", |
| 193 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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)), |
| 194 | ), |
| 195 | ( |
| 196 | "green", |
| 197 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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)), |
| 198 | ), |
| 199 | ( |
| 200 | "cyan", |
| 201 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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, 1.0)), |
| 202 | ), |
| 203 | ( |
| 204 | "magenta", |
| 205 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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, 1.0)), |
| 206 | ), |
| 207 | ( |
| 208 | "white", |
| 209 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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, 1.0, 1.0)), |
| 210 | ), |
| 211 | ( |
| 212 | "black", |
| 213 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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, 0.0)), |
| 214 | ), |
| 215 | ( |
| 216 | "grey", |
| 217 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(LinSrgbrust-analyzer cargo palette 0.7.6 rgb/LinSrgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.5, 0.5, 0.5)), |
| 218 | ), |
| 219 | ( |
| 220 | "yellow", |
| 221 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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, 1.0, 0.0)), |
| 222 | ), |
| 223 | ( |
| 224 | "blue", |
| 225 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(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)), |
| 226 | ), |
| 227 | ]; |
| 228 | |
| 229 | const EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON.: f64 = 1e-14; |
| 230 | |
| 231 | for (name, color) in colors { |
| 232 | let rgb: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8> = |
| 233 | craterust-analyzer cargo palette 0.7.6 crate/::Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::<f64>::from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Oklab<T>>`]from_color_unclamped().(color).into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().(); |
| 234 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 235 | "\n\ |
| 236 | roundtrip of {} (#{:x} / {:?})\n\ |
| 237 | =================================================", |
| 238 | name, rgb, color |
| 239 | ); |
| 240 | |
| 241 | let okhsv = Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#::from_color_unclampedrust-analyzer cargo palette 0.7.6 okhsv/impl#[`Okhsv<T>`][`FromColorUnclamped<Oklab<T>>`]from_color_unclamped().(color); |
| 242 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Okhsv: {:?}", okhsv); |
| 243 | let okhwb_from_okhsv = Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#::from_color_unclampedrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][`FromColorUnclamped<Okhsv<T>>`]from_color_unclamped().(okhsv); |
| 244 | let okhwb = Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#::from_color_unclampedrust-analyzer cargo palette 0.7.6 okhwb/impl#[`Okhwb<T>`][`FromColorUnclamped<crate::Oklab<T>>`]from_color_unclamped().(color); |
| 245 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Okhwb: {:?}", okhwb); |
| 246 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 247 | Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#::visually_eqrust-analyzer cargo palette 0.7.6 okhwb/visual_eq/impl#[`Okhwb<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(okhwb, okhwb_from_okhsv, EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON.), |
| 248 | "Okhwb \n{:?} is not visually equal to Okhwb from Okhsv \n{:?}\nwithin EPSILON {}", |
| 249 | okhwb, |
| 250 | okhwb_from_okhsv, |
| 251 | EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON. |
| 252 | ); |
| 253 | let okhsv_from_okhwb = Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#::from_color_unclampedrust-analyzer cargo palette 0.7.6 okhsv/impl#[`Okhsv<T>`][`FromColorUnclamped<Okhwb<T>>`]from_color_unclamped().(okhwb); |
| 254 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 255 | Okhsvrust-analyzer cargo palette 0.7.6 okhsv/Okhsv#::visually_eqrust-analyzer cargo palette 0.7.6 okhsv/visual_eq/impl#[`Okhsv<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(okhsv, okhsv_from_okhwb, EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON.), |
| 256 | "Okhsv \n{:?} is not visually equal to Okhsv from Okhsv from Okhwb \n{:?}\nwithin EPSILON {}", |
| 257 | okhsv, |
| 258 | okhsv_from_okhwb, EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON. |
| 259 | ); |
| 260 | |
| 261 | let roundtrip_color = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<crate::Okhwb<T>>`]from_color_unclamped().(okhwb); |
| 262 | let oklab_from_okhsv = Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::from_color_unclampedrust-analyzer cargo palette 0.7.6 oklab/impl#[`Oklab<T>`][`FromColorUnclamped<Okhsv<T>>`]from_color_unclamped().(okhsv); |
| 263 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 264 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(roundtrip_color, oklab_from_okhsv, EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON.), |
| 265 | "roundtrip color \n{:?} does not match \n{:?}\nwithin EPSILON {}", |
| 266 | roundtrip_color, |
| 267 | oklab_from_okhsv, |
| 268 | EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON. |
| 269 | ); |
| 270 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 271 | Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#::visually_eqrust-analyzer cargo palette 0.7.6 oklab/visual_eq/impl#[`Oklab<T>`][`VisuallyEqual<O, S, T>`]visually_eq().(roundtrip_color, color, EPSILONrust-analyzer cargo palette 0.7.6 okhwb/tests/conversion/EPSILON.), |
| 272 | "'{}' failed.\n\ |
| 273 | {:?}\n\ |
| 274 | !=\n\ |
| 275 | \n{:?}\n", |
| 276 | name, |
| 277 | roundtrip_color, |
| 278 | color |
| 279 | ); |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!( |
| 285 | Okhwbrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#[huerust-analyzer cargo palette 0.7.6 okhwb/Okhwb#hue., whitenessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#whiteness., blacknessrust-analyzer cargo palette 0.7.6 okhwb/Okhwb#blackness.], |
| 286 | superrust-analyzer cargo palette 0.7.6 okhwb/::Okhwbarust-analyzer cargo palette 0.7.6 okhwb/alpha/Okhwba#::newrust-analyzer cargo palette 0.7.6 okhwb/alpha/impl#[`Alpha<Okhwb<T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4), |
| 287 | superrust-analyzer cargo palette 0.7.6 okhwb/::Okhwbarust-analyzer cargo palette 0.7.6 okhwb/alpha/Okhwba#::newrust-analyzer cargo palette 0.7.6 okhwb/alpha/impl#[`Alpha<Okhwb<T>, A>`]new().(0.2, 0.3, 0.4, 0.5), |
| 288 | superrust-analyzer cargo palette 0.7.6 okhwb/::Okhwbarust-analyzer cargo palette 0.7.6 okhwb/alpha/Okhwba#::newrust-analyzer cargo palette 0.7.6 okhwb/alpha/impl#[`Alpha<Okhwb<T>, A>`]new().(0.3, 0.4, 0.5, 0.6) |
| 289 | ); |
| 290 | } |