Debian Codegraph @

src/okhsl/properties.rs

raw symbols SCIP
1 use crate::{hues::OklabHueIter, white_point::D65};
2
3 use crate::{
4 bool_mask::LazySelect,
5 num::{Arithmetics, PartialCmp, Real},
6 stimulus::Stimulus,
7 FromColor, OklabHue, Xyz,
8 };
9
10 use super::Okhsl;
11
12 impl_is_within_bounds! {
13 Okhsl {
14 saturation => [Self::min_saturation(), Self::max_saturation()],
15 lightness => [Self::min_lightness(), Self::max_lightness()]
16 }
17 where T: Stimulus
18 }
19 impl_clamp! {
20 Okhsl {
21 saturation => [Self::min_saturation(), Self::max_saturation()],
22 lightness => [Self::min_lightness(), Self::max_lightness()]
23 }
24 other {hue}
25 where T: Stimulus
26 }
27
28 impl_mix_hue!(Okhsl {
29 saturation,
30 lightness
31 });
32 impl_lighten!(Okhsl increase {lightness => [Self::min_lightness(), Self::max_lightness()]} other {hue, saturation} where T: Stimulus);
33 impl_saturate!(Okhsl increase {saturation => [Self::min_saturation(), Self::max_saturation()]} other {hue, lightness} where T: Stimulus);
34 impl_hue_ops!(Okhsl, OklabHue);
35
36 impl_color_add!(Okhsl, [hue, saturation, lightness]);
37 impl_color_sub!(Okhsl, [hue, saturation, lightness]);
38
39 impl_array_casts!(Okhsl<T>, [T; 3]);
40 impl_simd_array_conversion_hue!(Okhsl, [saturation, lightness]);
41 impl_struct_of_array_traits_hue!(Okhsl, OklabHueIter, [saturation, lightness]);
42
43 impl_eq_hue!(Okhsl, OklabHue, [hue, saturation, lightness]);
44
45 #[allow(deprecated)]
46 impl<T> crate::RelativeContrast for Okhsl<T>
47 where
48 T: Real + Arithmetics + PartialCmp,
49 T::Mask: LazySelect<T>,
50 Xyz<D65, T>: FromColor<Self>,
51 {
52 type Scalar = T;
53
54 #[inline]
55 fn get_contrast_ratio(self, other: Self) -> T {
56 let xyz1 = Xyz::from_color(self);
57 let xyz2 = Xyz::from_color(other);
58
59 crate::contrast_ratio(xyz1.y, xyz2.y)
60 }
61 }