Debian Codegraph @

src/hsv.rs

raw symbols SCIP
1 //! Types for the HSV color space.
2
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#, 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#};
4
5 use craterust-analyzer cargo palette 0.7.6 crate/::{
6 anglerust-analyzer cargo palette 0.7.6 angle/::{FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#, RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#},
7 bool_maskrust-analyzer cargo palette 0.7.6 bool_mask/::{BitOpsrust-analyzer cargo palette 0.7.6 bool_mask/BitOps#, BoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#, HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#, Selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#},
8 convertrust-analyzer cargo palette 0.7.6 convert/::FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#,
9 encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#,
10 huesrust-analyzer cargo palette 0.7.6 hues/::RgbHueIterrust-analyzer cargo palette 0.7.6 hues/RgbHueIter#,
11 numrust-analyzer cargo palette 0.7.6 num/::{Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#, MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#, Onerust-analyzer cargo palette 0.7.6 num/One#, PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, Realrust-analyzer cargo palette 0.7.6 num/Real#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#},
12 rgbrust-analyzer cargo palette 0.7.6 rgb/::{Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#, RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#},
13 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#},
14 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#, FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#, Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#,
15 };
16
17 /// Linear HSV with an alpha component. See the [`Hsva` implementation in
18 /// `Alpha`](crate::Alpha#Hsva).
19 pub type Hsvarust-analyzer cargo palette 0.7.6 hsv/Hsva#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> = Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>, T>;
20
21 /// HSV color space.
22 ///
23 /// HSV is a cylindrical version of [RGB](crate::rgb::Rgb) and it's very similar
24 /// to [HSL](crate::Hsl). The difference is that the `value` component in HSV
25 /// determines the _brightness_ of the color, and not the _lightness_. The
26 /// difference is that, for example, red (100% R, 0% G, 0% B) and white (100% R,
27 /// 100% G, 100% B) has the same brightness (or value), but not the same
28 /// lightness.
29 ///
30 /// HSV component values are typically real numbers (such as floats), but may
31 /// also be converted to and from `u8` for storage and interoperability
32 /// purposes. The hue is then within the range `[0, 255]`.
33 ///
34 /// ```
35 /// use approx::assert_relative_eq;
36 /// use palette::Hsv;
37 ///
38 /// let hsv_u8 = Hsv::new_srgb(128u8, 85, 51);
39 /// let hsv_f32 = hsv_u8.into_format::<f32>();
40 ///
41 /// assert_relative_eq!(hsv_f32, Hsv::new(180.0, 1.0 / 3.0, 0.2));
42 /// ```
43 #[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:)]
44 #[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))]
45 #[palette(
46 palette_internal,
47 rgb_standard = "S",
48 component = "T",
49 skip_derives(Rgb, Hsl, Hwb, Hsv)
50 )]
51 #[repr(C)]
52 #[doc(alias = "hsb")]
53 pub struct Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> {
54 /// The hue of the color, in degrees. Decides if it's red, blue, purple,
55 /// etc.
56 #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_same_layout_as = "T")]
57 pub huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>,
58
59 /// The colorfulness of the color. 0.0 gives gray scale colors and 1.0 will
60 /// give absolutely clear colors.
61 pub saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.: T,
62
63 /// Decides how bright the color will look. 0.0 will be black, and 1.0 will
64 /// give a bright an clear color that goes towards white when `saturation`
65 /// goes towards 0.0.
66 pub valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.: T,
67
68 /// The white point and RGB primaries this color is adapted to. The default
69 /// is the sRGB standard.
70 #[cfg_attr(feature = "serializing", serde(skip))]
71 #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_zero_sized)]
72 pub standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<S>,
73 }
74
75 impl<T> Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T> {
76 /// Create an sRGB HSV color. This method can be used instead of `Hsv::new`
77 /// to help type inference.
78 pub fn new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, saturation: T, value: T) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`] {
79 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]::new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, value)
80 }
81
82 /// Create an sRGB HSV color. This is the same as `Hsv::new_srgb` without
83 /// the generic hue type. It's temporary until `const fn` supports traits.
84 pub const fn new_srgb_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, value: T) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`] {
85 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]::new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new_const().(hue, saturation, value)
86 }
87 }
88
89 impl<S, T> Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T> {
90 /// Create an HSV color.
91 pub fn newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, saturation: T, value: T) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`] {
92 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]::new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, value)
93 }
94
95 /// Create an HSV color. This is the same as `Hsv::new` without the generic
96 /// hue type. It's temporary until `const fn` supports traits.
97 pub const fn new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, value: T) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`] {
98 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# {
99 huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.,
100 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.,
101 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.,
102 standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
103 }
104 }
105
106 /// Convert into another component type.
107 pub fn into_formatrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]into_format().<U>(self) -> Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, U>
108 where
109 U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<T>,
110 {
111 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# {
112 huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.: self.huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue..into_formatrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]into_format().(),
113 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.),
114 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.),
115 standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
116 }
117 }
118
119 /// Convert from another component type.
120 pub fn from_formatrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]from_format().<U>(color: Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, U>) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]
121 where
122 T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<U>,
123 {
124 color.into_formatrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]into_format().()
125 }
126
127 /// Convert to a `(hue, saturation, value)` tuple.
128 pub fn into_componentsrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]into_components().(self) -> (RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, T, T) {
129 (self.huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., self.saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., self.valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.)
130 }
131
132 /// Convert from a `(hue, saturation, value)` tuple.
133 pub fn from_componentsrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]from_components().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>((hue, saturation, value): (H, T, T)) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`] {
134 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]::newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new().(hue, saturation, value)
135 }
136
137 #[inline]
138 fn reinterpret_asrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]reinterpret_as().<St>(self) -> Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<St, T> {
139 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# {
140 huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.: self.huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.,
141 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.: self.saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.,
142 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.: self.valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.,
143 standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
144 }
145 }
146 }
147
148 impl<S, T> Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>
149 where
150 T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#,
151 {
152 /// Return the `saturation` value minimum.
153 pub fn min_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_saturation().() -> T {
154 T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()
155 }
156
157 /// Return the `saturation` value maximum.
158 pub fn max_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_saturation().() -> T {
159 T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().()
160 }
161
162 /// Return the `value` value minimum.
163 pub fn min_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_value().() -> T {
164 T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()
165 }
166
167 /// Return the `value` value maximum.
168 pub fn max_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_value().() -> T {
169 T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().()
170 }
171 }
172
173 ///<span id="Hsva"></span>[`Hsva`](crate::Hsva) implementations.
174 impl<T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T>, A> {
175 /// Create an sRGB HSV color with transparency. This method can be used
176 /// instead of `Hsva::new` to help type inference.
177 pub fn new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<Srgb, T>, A>`]new_srgb().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, saturation: T, value: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<Srgb, T>, A>`] {
178 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<Srgb, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, value, alpha)
179 }
180
181 /// Create an sRGB HSV color with transparency. This is the same as
182 /// `Hsva::new_srgb` without the generic hue type. It's temporary until
183 /// `const fn` supports traits.
184 pub const fn new_srgb_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<Srgb, T>, A>`]new_srgb_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, value: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<Srgb, T>, A>`] {
185 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<Srgb, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new_const().(hue, saturation, value, alpha)
186 }
187 }
188
189 ///<span id="Hsva"></span>[`Hsva`](crate::Hsva) implementations.
190 impl<S, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>, A> {
191 /// Create an HSV color with transparency.
192 pub fn newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(hue: H, saturation: T, value: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`] {
193 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]::new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new_const().(hue.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), saturation, value, alpha)
194 }
195
196 /// Create an HSV color with transparency. This is the same as `Hsva::new`
197 /// without the generic hue type. It's temporary until `const fn` supports
198 /// traits.
199 pub const fn new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new_const().(hue: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, saturation: T, value: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`] {
200 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# {
201 colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_construst-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new_const().(hue, saturation, value),
202 alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.,
203 }
204 }
205
206 /// Convert into another component type.
207 pub fn into_formatrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]into_format().<U, B>(self) -> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, U>, B>
208 where
209 U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<T>,
210 B: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<A>,
211 {
212 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# {
213 colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..into_formatrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]into_format().(),
214 alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.: B::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.),
215 }
216 }
217
218 /// Convert from another component type.
219 pub fn from_formatrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]from_format().<U, B>(color: Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, U>, B>) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]
220 where
221 T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U> + FromAnglerust-analyzer cargo palette 0.7.6 angle/FromAngle#<U>,
222 A: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<B>,
223 {
224 color.into_formatrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]into_format().()
225 }
226
227 /// Convert to a `(hue, saturation, value, alpha)` tuple.
228 pub fn into_componentsrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]into_components().(self) -> (RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>, T, T, A) {
229 (
230 self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.,
231 self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.,
232 self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.,
233 self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.,
234 )
235 }
236
237 /// Convert from a `(hue, saturation, value, alpha)` tuple.
238 pub fn from_componentsrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]from_components().<H: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>>>(
239 (hue, saturation, value, alpha): (H, T, T, A),
240 ) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`] {
241 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]::newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new().(hue, saturation, value, alpha)
242 }
243 }
244
245 impl_reference_component_methods_huerust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods_hue!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, [saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.], standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
246 impl_struct_of_arrays_methods_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods_hue!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, [saturation, value], standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
247
248 impl<S1, S2, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S1, T>> for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S2, T>
249 where
250 S1: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static,
251 S2: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static,
252 S1::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# = <S2::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#>,
253 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S1, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S1, T>>,
254 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S2, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S1, T>>,
255 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S2, T>`][`FromColorUnclamped<Hsv<S1, T>>`]: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S2, T>>,
256 {
257 #[inline]
258 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S2, T>`][`FromColorUnclamped<Hsv<S1, T>>`]from_color_unclamped().(hsv: Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S1, T>) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S2, T>`][`FromColorUnclamped<Hsv<S1, T>>`] {
259 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<S1>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<S2>() {
260 hsv.reinterpret_asrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]reinterpret_as().()
261 } else {
262 let rgb = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<S1, T>::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(hsv);
263 let converted_rgb = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<S2, T>::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(rgb);
264 Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S2, T>`][`FromColorUnclamped<Hsv<S1, T>>`]::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(converted_rgb)
265 }
266 }
267 }
268
269 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>> for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>
270 where
271 T: RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# + Onerust-analyzer cargo palette 0.7.6 num/One# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax# + 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#,
272 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: BoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/BoolMask# + BitOpsrust-analyzer cargo palette 0.7.6 bool_mask/BitOps# + 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# + 'static,
273 {
274 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][`FromColorUnclamped<Rgb<S, T>>`]from_color_unclamped().(rgb: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][`FromColorUnclamped<Rgb<S, T>>`] {
275 // Avoid negative numbers
276 let red = rgb.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red..maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().());
277 let green = rgb.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green..maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().());
278 let blue = rgb.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue..maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().());
279
280 // The SIMD optimized version showed significant slowdown for regular floats.
281 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<bool>() {
282 let (max, min, sep, coeff) = {
283 let (max, min, sep, coeff) = if red.gtrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt().(&green).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() {
284 (red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), green.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().&blue, T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().())
285 } else {
286 (
287 green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
288 red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
289 blue.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().&red,
290 T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0),
291 )
292 };
293 if blue.gtrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt().(&max).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() {
294 (blue, min, red 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().green, T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0))
295 } else {
296 let min_val = if blue.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&min).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() { blue } else { min };
297 (max, min_val, sep, coeff)
298 }
299 };
300
301 let (h, s) = if max.neqrust-analyzer cargo palette 0.7.6 num/PartialCmp#neq().(&min).is_truerust-analyzer cargo palette 0.7.6 bool_mask/BoolMask#is_true().() {
302 let d = max.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().min;
303 let h = ((sep 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().&d) 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().coeff) 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().(60.0);
304 let s = d 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().&max;
305
306 (h, s)
307 } else {
308 (T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().())
309 };
310 let v = max;
311
312 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# {
313 huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.: h.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
314 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.: s,
315 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.: v,
316 standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
317 }
318 } else {
319 // Based on OPTIMIZED RGB TO HSV COLOR CONVERSION USING SSE TECHNOLOGY
320 // by KOBALICEK, Petr & BLIZNAK, Michal
321 //
322 // This implementation assumes less about the underlying mask and number
323 // representation. The hue is also multiplied by 6 to avoid rounding
324 // errors when using degrees.
325
326 let six = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(6.0);
327
328 let value = red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()).maxrust-analyzer cargo palette 0.7.6 num/MinMax#max().(blue.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
329 let min = red.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().minrust-analyzer cargo palette 0.7.6 num/MinMax#min().(green.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()).minrust-analyzer cargo palette 0.7.6 num/MinMax#min().(blue.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
330
331 let chroma = value.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/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().min;
332 let saturation = chroma
333 .eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().())
334 .lazy_selectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#lazy_select().(|| T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(), || chroma.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/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().&value);
335
336 // Each of these represents an RGB component. The maximum will be false
337 // while the two other will be true. They are later used for determining
338 // which branch in the hue equation we end up in.
339 let x = value.neqrust-analyzer cargo palette 0.7.6 num/PartialCmp#neq().(&red);
340 let y = value.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&red) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().value.neqrust-analyzer cargo palette 0.7.6 num/PartialCmp#neq().(&green);
341 let z = value.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&red) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor().value.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&green);
342
343 // The hue base is the `1`, `2/6`, `4/6` or 0 part of the hue equation,
344 // except it's multiplied by 6 here.
345 let hue_base = x.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(
346 z.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().4.0), T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0)),
347 T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
348 ) 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().&six;
349
350 // Each of these is a part of `G - B`, `B - R`, `R - G` or 0 from the
351 // hue equation. They become positive, negative or 0, depending on which
352 // branch we should be in. This makes the sum of all three combine as
353 // expected.
354 let red_m = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
355 if x => y.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(red.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/Neg#neg().red),
356 else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
357 };
358 let green_m = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
359 if y.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() => z.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().().selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(green.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/Neg#neg().green),
360 else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
361 };
362 let blue_m = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
363 if z => y.selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Neg#neg().blue.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), blue),
364 else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
365 };
366
367 // This is the hue equation parts combined. The hue base is the constant
368 // and the RGB components are masked so up to two of them are non-zero.
369 // Once again, this is multiplied by 6, so the chroma isn't multiplied
370 // before dividing.
371 //
372 // We also avoid dividing by 0 for non-SIMD values.
373 let hue = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
374 if chroma.eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()) => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
375 else => hue_base +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). (red_m +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). green_m +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). blue_m) /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). &chroma,
376 };
377
378 // hue will always be within [0, 12) (it's multiplied by 6, compared to
379 // the paper), so we can subtract by 6 instead of using % to get it
380 // within [0, 6).
381 let hue_sub = hue.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&six).selectrust-analyzer cargo palette 0.7.6 bool_mask/Select#select().(six, T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().());
382 let hue = hue 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().hue_sub;
383
384 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# {
385 huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.: RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#::from_degreesrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]from_degrees().(hue 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().(60.0)),
386 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.,
387 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.,
388 standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
389 }
390 }
391 }
392 }
393
394 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T>> for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>
395 where
396 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + 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# + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
397 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>,
398 {
399 #[inline]
400 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][`FromColorUnclamped<Hsl<S, T>>`]from_color_unclamped().(hsl: Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][`FromColorUnclamped<Hsl<S, T>>`] {
401 let x = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
402 if hsl.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness..ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5)) => hsl.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
403 else => 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(). &hsl.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness.,
404 } 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().hsl.saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.;
405
406 let value = hsl.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness. 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().&x;
407
408 // avoid divide by zero
409 let saturation = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
410 if value.is_valid_divisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#is_valid_divisor().() => x *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.0) /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). &value,
411 else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
412 };
413
414 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# {
415 huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.: hsl.huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue.,
416 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.,
417 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.,
418 standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
419 }
420 }
421 }
422
423 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T>> for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>
424 where
425 T: Onerust-analyzer cargo palette 0.7.6 num/One# + Zerorust-analyzer cargo palette 0.7.6 num/Zero# + IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#,
426 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>,
427 {
428 #[inline]
429 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][`FromColorUnclamped<Hwb<S, T>>`]from_color_unclamped().(hwb: Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][`FromColorUnclamped<Hwb<S, T>>`] {
430 let Hwbrust-analyzer cargo palette 0.7.6 hwb/Hwb# {
431 huerust-analyzer cargo palette 0.7.6 hwb/Hwb#hue.,
432 whitenessrust-analyzer cargo palette 0.7.6 hwb/Hwb#whiteness.,
433 blacknessrust-analyzer cargo palette 0.7.6 hwb/Hwb#blackness.,
434 ..
435 } = hwb;
436
437 let value = 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().blackness;
438
439 // avoid divide by zero
440 let saturation = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
441 if value.is_valid_divisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#is_valid_divisor().() => 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(). (whiteness /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). &value),
442 else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
443 };
444
445 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# {
446 huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue.,
447 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.,
448 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.,
449 standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
450 }
451 }
452 }
453
454 impl_tuple_conversion_huerust-analyzer cargo palette 0.7.6 macros/convert/impl_tuple_conversion_hue!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S> as (H, T, T), RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#);
455
456 impl_is_within_boundsrust-analyzer cargo palette 0.7.6 macros/clamp/impl_is_within_bounds!! {
457 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S> {
458 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation. => [Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][IsWithinBounds]::min_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_saturation().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][IsWithinBounds]::max_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_saturation().()],
459 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value. => [Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][IsWithinBounds]::min_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_value().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][IsWithinBounds]::max_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_value().()]
460 }
461 where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#
462 }
463 impl_clamprust-analyzer cargo palette 0.7.6 macros/clamp/impl_clamp!! {
464 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S> {
465 saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation. => [Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][ClampAssign]::min_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_saturation().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][ClampAssign]::max_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_saturation().()],
466 valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value. => [Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][ClampAssign]::min_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_value().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][ClampAssign]::max_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_value().()]
467 }
468 other {huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.}
469 where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#
470 }
471
472 impl_mix_huerust-analyzer cargo palette 0.7.6 macros/mix/impl_mix_hue!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S> {saturation, value} phantom: standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
473 impl_lightenrust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_lighten!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S> increase {value => [Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][Lighten]::min_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_value().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][Lighten]::max_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_value().()]} other {huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.} phantom: standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard. where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#);
474 impl_saturaterust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_saturate!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S> increase {saturation => [Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][Saturate]::min_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_saturation().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][Saturate]::max_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_saturation().()]} other {huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.} phantom: standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard. where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#);
475 impl_hue_opsrust-analyzer cargo palette 0.7.6 macros/hue/impl_hue_ops!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#);
476
477 impl<S, T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>
478 where
479 T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#,
480 {
481 type Maskrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#;
482 }
483
484 impl<S, T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>
485 where
486 T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#,
487 RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#,
488 {
489 fn defaultrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][Default]default().() -> Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T> {
490 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new().(RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][Default]::min_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_saturation().(), Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][Default]::min_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_value().())
491 }
492 }
493
494 impl_color_addrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_add!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, [huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.], standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
495 impl_color_subrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_sub!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, [huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.], standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
496
497 impl_array_castsrust-analyzer cargo palette 0.7.6 macros/casting/impl_array_casts!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>, [T; 3]);
498 impl_simd_array_conversion_huerust-analyzer cargo palette 0.7.6 macros/simd/impl_simd_array_conversion_hue!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, [saturation, value], standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
499 impl_struct_of_array_traits_huerust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_array_traits_hue!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, RgbHueIterrust-analyzer cargo palette 0.7.6 hues/RgbHueIter#, [saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.], standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
500
501 impl_eq_huerust-analyzer cargo palette 0.7.6 macros/equality/impl_eq_hue!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#, [huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.]);
502 impl_copy_clonerust-analyzer cargo palette 0.7.6 macros/copy_clone/impl_copy_clone!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S>, [huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.], standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.);
503
504 #[allow(deprecated)]
505 impl<S, T> craterust-analyzer cargo palette 0.7.6 crate/::RelativeContrastrust-analyzer cargo palette 0.7.6 relative_contrast/RelativeContrast# for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>
506 where
507 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#,
508 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>,
509 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#,
510 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#, T>: FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#<Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][RelativeContrast]>,
511 {
512 type Scalarrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][RelativeContrast]Scalar# = T;
513
514 #[inline]
515 fn get_contrast_ratiorust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][RelativeContrast]get_contrast_ratio().(self, other: Selfrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`][RelativeContrast]) -> T {
516 let xyz1 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(self);
517 let xyz2 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(other);
518
519 craterust-analyzer cargo palette 0.7.6 crate/::contrast_ratiorust-analyzer cargo palette 0.7.6 relative_contrast/contrast_ratio().(xyz1.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., xyz2.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.)
520 }
521 }
522
523 impl_rand_traits_hsv_conerust-analyzer cargo palette 0.7.6 macros/random/impl_rand_traits_hsv_cone!!(
524 UniformHsvrust-analyzer cargo palette 0.7.6 hsv/UniformHsv#,
525 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S> {
526 hue: UniformRgbHuerust-analyzer cargo palette 0.7.6 hues/UniformRgbHue# => RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#,
527 height: value,
528 radius: saturation
529 }
530 phantom: standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.: PhantomData<S>
531 );
532
533 #[cfg(feature = "bytemuck")]
534 unsafe impl<S, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {}
535
536 #[cfg(feature = "bytemuck")]
537 unsafe impl<S: 'static, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {}
538
539 #[cfg(test)]
540 mod testrust-analyzer cargo palette 0.7.6 hsv/test/ {
541 use superrust-analyzer cargo palette 0.7.6 hsv/::Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#;
542
543 test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#);
544
545 #[cfg(feature = "approx")]
546 mod conversionrust-analyzer cargo palette 0.7.6 hsv/test/conversion/ {
547 use craterust-analyzer cargo palette 0.7.6 crate/::{FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#, Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#, Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#};
548
549 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
550 fn redrust-analyzer cargo palette 0.7.6 hsv/test/conversion/red().() {
551 let a = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1.0, 0.0, 0.0));
552 let b = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(0.0, 1.0, 1.0);
553 let c = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(0.0, 1.0, 0.5));
554
555 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b);
556 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c);
557 }
558
559 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
560 fn orangerust-analyzer cargo palette 0.7.6 hsv/test/conversion/orange().() {
561 let a = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1.0, 0.5, 0.0));
562 let b = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(30.0, 1.0, 1.0);
563 let c = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(30.0, 1.0, 0.5));
564
565 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b);
566 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c);
567 }
568
569 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
570 fn greenrust-analyzer cargo palette 0.7.6 hsv/test/conversion/green().() {
571 let a = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.0, 1.0, 0.0));
572 let b = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(120.0, 1.0, 1.0);
573 let c = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(120.0, 1.0, 0.5));
574
575 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b);
576 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c);
577 }
578
579 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
580 fn bluerust-analyzer cargo palette 0.7.6 hsv/test/conversion/blue().() {
581 let a = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.0, 0.0, 1.0));
582 let b = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(240.0, 1.0, 1.0);
583 let c = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(240.0, 1.0, 0.5));
584
585 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b);
586 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c);
587 }
588
589 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
590 fn purplerust-analyzer cargo palette 0.7.6 hsv/test/conversion/purple().() {
591 let a = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Srgbrust-analyzer cargo palette 0.7.6 rgb/Srgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.5, 0.0, 1.0));
592 let b = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(270.0, 1.0, 1.0);
593 let c = Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/impl#[U][`FromColor<T>`]from_color().(Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#::new_srgbrust-analyzer cargo palette 0.7.6 hsl/impl#[`Hsl<Srgb, T>`]new_srgb().(270.0, 1.0, 0.5));
594
595 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, b);
596 assert_relative_eqrust-analyzer cargo approx 0.5.1 macros/assert_relative_eq!!(a, c);
597 }
598 }
599
600 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
601 fn rangesrust-analyzer cargo palette 0.7.6 hsv/test/ranges().() {
602 assert_rangesrust-analyzer cargo palette 0.7.6 macros/clamp/assert_ranges!! {
603 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f64>;
604 clamped {
605 saturation: 0.0 => 1.0,
606 value: 0.0 => 1.0
607 }
608 clamped_min {}
609 unclamped {
610 hue: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().360.0 => 360.0
611 }
612 }
613 }
614
615 raw_pixel_conversion_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_tests!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>: hue, saturation, value);
616 raw_pixel_conversion_fail_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_fail_tests!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>: hue, saturation, value);
617
618 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
619 fn check_min_max_componentsrust-analyzer cargo palette 0.7.6 hsv/test/check_min_max_components().() {
620 use craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#;
621
622 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::min_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_saturation().(), 0.0,);
623 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::min_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]min_value().(), 0.0,);
624 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::max_saturationrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_saturation().(), 1.0,);
625 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::max_valuerust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]max_value().(), 1.0,);
626 }
627
628 struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!(
629 Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>[huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue., saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation., valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value.] phantom: standardrust-analyzer cargo palette 0.7.6 hsv/Hsv#standard.,
630 superrust-analyzer cargo palette 0.7.6 hsv/::Hsvarust-analyzer cargo palette 0.7.6 hsv/Hsva#::newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4),
631 superrust-analyzer cargo palette 0.7.6 hsv/::Hsvarust-analyzer cargo palette 0.7.6 hsv/Hsva#::newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new().(0.2, 0.3, 0.4, 0.5),
632 superrust-analyzer cargo palette 0.7.6 hsv/::Hsvarust-analyzer cargo palette 0.7.6 hsv/Hsva#::newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Alpha<Hsv<S, T>, A>`]new().(0.3, 0.4, 0.5, 0.6)
633 );
634
635 #[cfg(feature = "serializing")]
636 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
637 fn serializerust-analyzer cargo palette 0.7.6 hsv/test/serialize().() {
638 let serialized = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::to_stringrust-analyzer cargo serde_json 1.0.116 ser/to_string().(&Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::new_srgbrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<Srgb, T>`]new_srgb().(0.3, 0.8, 0.1)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
639
640 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#"{"hue":0.3,"saturation":0.8,"value":0.1}"#);
641 }
642
643 #[cfg(feature = "serializing")]
644 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
645 fn deserializerust-analyzer cargo palette 0.7.6 hsv/test/deserialize().() {
646 let deserialized: Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv# =
647 ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::from_strrust-analyzer cargo serde_json 1.0.116 de/from_str().(r#"{"hue":0.3,"saturation":0.8,"value":0.1}"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
648
649 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#::newrust-analyzer cargo palette 0.7.6 hsv/impl#[`Hsv<S, T>`]new().(0.3, 0.8, 0.1));
650 }
651
652 test_uniform_distributionrust-analyzer cargo palette 0.7.6 macros/random/test_uniform_distribution!! {
653 Hsv<crate::encoding::Srgb, f32> as crate::rgb::Rgb {
654 red: (0.0, 1.0),
655 green: (0.0, 1.0),
656 blue: (0.0, 1.0)
657 },
658 min: Hsv::new(0.0f32, 0.0, 0.0),
659 max: Hsv::new(360.0, 1.0, 1.0)
660 }
661 }