palette/macros/
hue.rs

1macro_rules! impl_hue_ops {
2    (  $self_ty: ident , $hue_ty: ident) => {
3        impl_hue_ops!($self_ty<>, $hue_ty);
4    };
5    (  $self_ty: ident < $($ty_param: ident),* > , $hue_ty: ident) => {
6        impl<$($ty_param,)* T> crate::GetHue for $self_ty<$($ty_param,)* T>
7        where
8            T: Clone,
9        {
10            type Hue = $hue_ty<T>;
11
12            #[inline]
13            fn get_hue(&self) -> $hue_ty<T> {
14                self.hue.clone()
15            }
16        }
17
18        impl<$($ty_param,)* T, H> crate::WithHue<H> for $self_ty<$($ty_param,)* T>
19        where
20            H: Into<$hue_ty<T>>,
21        {
22            #[inline]
23            fn with_hue(mut self, hue: H) -> Self {
24                self.hue = hue.into();
25                self
26            }
27        }
28
29        impl<$($ty_param,)* T, H> crate::SetHue<H> for $self_ty<$($ty_param,)* T>
30        where
31            H: Into<$hue_ty<T>>,
32        {
33            #[inline]
34            fn set_hue(&mut self, hue: H) {
35                self.hue = hue.into();
36            }
37        }
38
39        impl<$($ty_param,)* T> crate::ShiftHue for $self_ty<$($ty_param,)* T>
40        where
41            T: core::ops::Add<Output = T>,
42        {
43            type Scalar = T;
44
45            #[inline]
46            fn shift_hue(mut self, amount: Self::Scalar) -> Self {
47                self.hue = self.hue + amount;
48                self
49            }
50        }
51
52        impl<$($ty_param,)* T> crate::ShiftHueAssign for $self_ty<$($ty_param,)* T>
53        where
54            T: core::ops::AddAssign,
55        {
56            type Scalar = T;
57
58            #[inline]
59            fn shift_hue_assign(&mut self, amount: Self::Scalar) {
60                self.hue += amount;
61            }
62        }
63    }
64}