1use crate::RGB;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5pub enum Gradient {
6 Atlast,
8 Cristal,
10 Teen,
12 Mind,
14 Morning,
16 Vice,
18 Passion,
20 Fruit,
22 Retro,
24 Summer,
26 Rainbow,
28 Pastel,
30 Monsoon,
32 Forest,
34 Instagram,
36}
37
38impl IntoIterator for &Gradient {
39 type Item = RGB;
40 type IntoIter = GradientIter<'static>;
41
42 fn into_iter(self) -> Self::IntoIter {
43 let colors = match self {
44 Gradient::Atlast => GRADIENT_ATLAST.as_ref(),
45 Gradient::Cristal => GRADIENT_CRISTAL.as_ref(),
46 Gradient::Teen => GRADIENT_TEEN.as_ref(),
47 Gradient::Mind => GRADIENT_MIND.as_ref(),
48 Gradient::Morning => GRADIENT_MORNING.as_ref(),
49 Gradient::Vice => GRADIENT_VICE.as_ref(),
50 Gradient::Passion => GRADIENT_PASSION.as_ref(),
51 Gradient::Fruit => GRADIENT_FRUIT.as_ref(),
52 Gradient::Retro => GRADIENT_RETRO.as_ref(),
53 Gradient::Summer => GRADIENT_SUMMER.as_ref(),
54 Gradient::Rainbow => GRADIENT_RAINBOW.as_ref(),
55 Gradient::Pastel => GRADIENT_PASTEL.as_ref(),
56 Gradient::Monsoon => GRADIENT_MONSOON.as_ref(),
57 Gradient::Forest => GRADIENT_FOREST.as_ref(),
58 Gradient::Instagram => GRADIENT_INSTAGRAM.as_ref(),
59 };
60
61 GradientIter {
62 colors: colors.iter(),
63 }
64 }
65}
66
67impl IntoIterator for Gradient {
68 type Item = RGB;
69 type IntoIter = GradientIter<'static>;
70
71 fn into_iter(self) -> Self::IntoIter {
72 (&self).into_iter()
73 }
74}
75
76const GRADIENT_ATLAST: [RGB; 3] = [
77 RGB::new(0xFE, 0xAC, 0x5E),
78 RGB::new(0xC7, 0x9D, 0xD0),
79 RGB::new(0x4B, 0xC0, 0xC8),
80];
81
82const GRADIENT_CRISTAL: [RGB; 2] = [RGB::new(0xBD, 0xFF, 0xF3), RGB::new(0x5A, 0xC2, 0x9A)];
83
84const GRADIENT_TEEN: [RGB; 3] = [
85 RGB::new(0x77, 0xA1, 0xD3),
86 RGB::new(0x79, 0xCB, 0xCA),
87 RGB::new(0xE6, 0x84, 0xAE),
88];
89
90const GRADIENT_MORNING: [RGB; 2] = [RGB::new(0xFF, 0x5F, 0x6D), RGB::new(0xFF, 0xC3, 0x71)];
91
92const GRADIENT_VICE: [RGB; 2] = [RGB::new(0x5E, 0xE7, 0xDF), RGB::new(0xB4, 0x90, 0xCA)];
93
94const GRADIENT_PASSION: [RGB; 2] = [RGB::new(0xF4, 0x3B, 0x47), RGB::new(0x45, 0x3A, 0x94)];
95
96const GRADIENT_FRUIT: [RGB; 2] = [RGB::new(0xFF, 0x4E, 0x50), RGB::new(0xF9, 0xD4, 0x23)];
97
98const GRADIENT_SUMMER: [RGB; 2] = [RGB::new(0xfd, 0xbb, 0x2d), RGB::new(0x22, 0xc1, 0xc3)];
99
100const GRADIENT_MIND: [RGB; 3] = [
101 RGB::new(0x47, 0x3B, 0x7B),
102 RGB::new(0x35, 0x84, 0xA7),
103 RGB::new(0x30, 0xD2, 0xBE),
104];
105
106const GRADIENT_RETRO: [RGB; 9] = [
107 RGB::new(0x3f, 0x51, 0xb1),
108 RGB::new(0x5a, 0x55, 0xae),
109 RGB::new(0x7b, 0x5f, 0xac),
110 RGB::new(0x8f, 0x6a, 0xae),
111 RGB::new(0xa8, 0x6a, 0xa4),
112 RGB::new(0xcc, 0x6b, 0x8e),
113 RGB::new(0xf1, 0x82, 0x71),
114 RGB::new(0xf3, 0xa4, 0x69),
115 RGB::new(0xf7, 0xc9, 0x78),
116];
117
118const GRADIENT_RAINBOW: [RGB; 6] = [
119 RGB::new(189, 19, 84),
120 RGB::new(228, 108, 33),
121 RGB::new(226, 166, 29),
122 RGB::new(46, 163, 44),
123 RGB::new(54, 83, 238),
124 RGB::new(87, 32, 131),
125];
126
127const GRADIENT_PASTEL: [RGB; 5] = [
128 RGB::new(255, 223, 204),
129 RGB::new(255, 243, 219),
130 RGB::new(203, 235, 195),
131 RGB::new(173, 215, 219),
132 RGB::new(137, 143, 173),
133];
134
135const GRADIENT_MONSOON: [RGB; 6] = [
136 RGB::new(181, 199, 204),
137 RGB::new(139, 161, 173),
138 RGB::new(88, 123, 137),
139 RGB::new(36, 76, 102),
140 RGB::new(64, 125, 108),
141 RGB::new(125, 178, 144),
142];
143
144const GRADIENT_FOREST: [RGB; 5] = [
145 RGB::new(69, 55, 48),
146 RGB::new(130, 94, 65),
147 RGB::new(44, 62, 57),
148 RGB::new(65, 90, 69),
149 RGB::new(108, 112, 88),
150];
151
152const GRADIENT_INSTAGRAM: [RGB; 3] = [
153 RGB::new(0x83, 0x3a, 0xb4),
154 RGB::new(0xfd, 0x1d, 0x1d),
155 RGB::new(0xfc, 0xb0, 0x45),
156];
157
158#[derive(Debug, Clone)]
159pub struct GradientIter<'a> {
160 colors: core::slice::Iter<'a, RGB>,
161}
162
163impl Iterator for GradientIter<'_> {
164 type Item = RGB;
165
166 fn next(&mut self) -> Option<Self::Item> {
167 self.colors.next().copied()
168 }
169}
170
171impl ExactSizeIterator for GradientIter<'_> {
172 fn len(&self) -> usize {
173 self.colors.len()
174 }
175}