color_gradient/blenders/hsv/
builtin.rs

1use super::*;
2
3impl Default for HsvGradient {
4    fn default() -> Self {
5        HsvGradient::standard(0.0, 1.0)
6    }
7}
8
9/// standard hsv color maps
10impl HsvGradient {
11    /// Standard color map in HSV color space.
12    /// - step: ![standard-step.png](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/standard-step.png)
13    /// - linear: ![standard-linear.png](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/standard-linear.png)
14    pub fn standard(min: f32, max: f32) -> HsvGradient {
15        let mut grad = HsvGradient::new(0.0, 360.0);
16        grad.insert_hue(0.0, 0.0);
17        grad.insert_hue(60.0, 60.0);
18        grad.insert_hue(120.0, 120.0);
19        grad.insert_hue(180.0, 180.0);
20        grad.insert_hue(240.0, 240.0);
21        grad.insert_hue(300.0, 300.0);
22        grad.insert_hue(360.0, 360.0);
23        grad.rescale(min, max);
24        grad
25    }
26}
27
28/// matlab color maps
29impl HsvGradient {
30    /// Parula color map in HSV color space.
31    /// - step:
32    /// ![parula-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/parula-step.png)
33    /// - linear:
34    /// ![parula-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/parula-linear.png)
35    pub fn parula(min: f32, max: f32) -> HsvGradient {
36        let mut grad = HsvGradient::new(0.0, 430.00);
37        grad.insert_hue(0.00, 251.08);
38        grad.insert_saturation(0.00, 77.38);
39        grad.insert_brightness(0.00, 65.88);
40        grad.insert_hue(43.00, 241.83);
41        grad.insert_saturation(43.00, 71.30);
42        grad.insert_brightness(43.00, 90.20);
43        grad.insert_hue(86.00, 229.30);
44        grad.insert_saturation(86.00, 73.12);
45        grad.insert_brightness(86.00, 99.22);
46        grad.insert_hue(129.00, 211.66);
47        grad.insert_saturation(129.00, 81.56);
48        grad.insert_brightness(129.00, 95.69);
49        grad.insert_hue(172.00, 196.31);
50        grad.insert_saturation(172.00, 87.44);
51        grad.insert_brightness(172.00, 87.45);
52        grad.insert_hue(215.00, 178.62);
53        grad.insert_saturation(215.00, 91.58);
54        grad.insert_brightness(215.00, 74.51);
55        grad.insert_hue(258.00, 148.40);
56        grad.insert_saturation(258.00, 64.53);
57        grad.insert_brightness(258.00, 79.61);
58        grad.insert_hue(301.00, 79.70);
59        grad.insert_saturation(301.00, 66.67);
60        grad.insert_brightness(301.00, 78.82);
61        grad.insert_hue(344.00, 44.52);
62        grad.insert_saturation(344.00, 79.49);
63        grad.insert_brightness(344.00, 91.76);
64        grad.insert_hue(387.00, 49.12);
65        grad.insert_saturation(387.00, 81.60);
66        grad.insert_brightness(387.00, 98.04);
67        grad.insert_hue(430.00, 60.52);
68        grad.insert_saturation(430.00, 91.63);
69        grad.insert_brightness(430.00, 98.43);
70        grad.rescale(min, max);
71        grad
72    }
73    /// Jet color map in HSV color space.
74    /// - step:
75    /// ![jet-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/jet-step.png)
76    /// - linear:
77    /// ![jet-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/jet-linear.png)
78    pub fn jet(min: f32, max: f32) -> HsvGradient {
79        let mut grad = HsvGradient::new(0.0, 430.00);
80        grad.insert_hue(0.00, 240.00);
81        grad.insert_saturation(0.00, 100.00);
82        grad.insert_brightness(0.00, 51.37);
83        grad.insert_hue(43.00, 240.00);
84        grad.insert_saturation(43.00, 100.00);
85        grad.insert_brightness(43.00, 90.59);
86        grad.insert_hue(86.00, 222.12);
87        grad.insert_saturation(86.00, 100.00);
88        grad.insert_brightness(86.00, 100.00);
89        grad.insert_hue(129.00, 197.88);
90        grad.insert_saturation(129.00, 100.00);
91        grad.insert_brightness(129.00, 100.00);
92        grad.insert_hue(172.00, 172.60);
93        grad.insert_saturation(172.00, 89.02);
94        grad.insert_brightness(172.00, 100.00);
95        grad.insert_hue(215.00, 120.00);
96        grad.insert_saturation(215.00, 49.80);
97        grad.insert_brightness(215.00, 100.00);
98        grad.insert_hue(258.00, 66.23);
99        grad.insert_saturation(258.00, 90.59);
100        grad.insert_brightness(258.00, 100.00);
101        grad.insert_hue(301.00, 42.12);
102        grad.insert_saturation(301.00, 100.00);
103        grad.insert_brightness(301.00, 100.00);
104        grad.insert_hue(344.00, 17.88);
105        grad.insert_saturation(344.00, 100.00);
106        grad.insert_brightness(344.00, 100.00);
107        grad.insert_hue(387.00, 0.00);
108        grad.insert_saturation(387.00, 100.00);
109        grad.insert_brightness(387.00, 89.02);
110        grad.insert_hue(430.00, 0.00);
111        grad.insert_saturation(430.00, 100.00);
112        grad.insert_brightness(430.00, 50.20);
113        grad.rescale(min, max);
114        grad
115    }
116    /// Turbo color map in HSV color space.
117    /// - step:
118    /// ![turbo-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/turbo-step.png)
119    /// - linear:
120    /// ![turbo-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/turbo-linear.png)
121    pub fn turbo(min: f32, max: f32) -> HsvGradient {
122        let mut grad = HsvGradient::new(0.0, 430.00);
123        grad.insert_hue(0.00, 283.90);
124        grad.insert_saturation(0.00, 69.49);
125        grad.insert_brightness(0.00, 23.14);
126        grad.insert_hue(43.00, 231.04);
127        grad.insert_saturation(43.00, 66.01);
128        grad.insert_brightness(43.00, 79.61);
129        grad.insert_hue(86.00, 212.04);
130        grad.insert_saturation(86.00, 74.90);
131        grad.insert_brightness(86.00, 100.00);
132        grad.insert_hue(129.00, 177.45);
133        grad.insert_saturation(129.00, 88.26);
134        grad.insert_brightness(129.00, 83.53);
135        grad.insert_hue(172.00, 140.90);
136        grad.insert_saturation(172.00, 71.77);
137        grad.insert_brightness(172.00, 97.25);
138        grad.insert_hue(215.00, 88.75);
139        grad.insert_saturation(215.00, 75.89);
140        grad.insert_brightness(215.00, 99.22);
141        grad.insert_hue(258.00, 58.59);
142        grad.insert_saturation(258.00, 75.56);
143        grad.insert_brightness(258.00, 88.24);
144        grad.insert_hue(301.00, 34.41);
145        grad.insert_saturation(301.00, 80.31);
146        grad.insert_brightness(301.00, 99.61);
147        grad.insert_hue(344.00, 19.73);
148        grad.insert_saturation(344.00, 92.50);
149        grad.insert_brightness(344.00, 94.12);
150        grad.insert_hue(387.00, 10.63);
151        grad.insert_saturation(387.00, 98.46);
152        grad.insert_brightness(387.00, 76.47);
153        grad.insert_hue(430.00, 0.50);
154        grad.insert_saturation(430.00, 97.54);
155        grad.insert_brightness(430.00, 47.84);
156        grad.rescale(min, max);
157        grad
158    }
159    /// Hot color map in HSV color space.
160    /// - step:
161    /// ![hot-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/hot-step.png)
162    /// - linear:
163    /// ![hot-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/hot-linear.png)
164    pub fn hot(min: f32, max: f32) -> HsvGradient {
165        let mut grad = HsvGradient::new(0.0, 420.00);
166        grad.insert_hue(0.00, 0.00);
167        grad.insert_saturation(0.00, 100.00);
168        grad.insert_brightness(0.00, 1.18);
169        grad.insert_hue(42.00, 0.00);
170        grad.insert_saturation(42.00, 100.00);
171        grad.insert_brightness(42.00, 25.88);
172        grad.insert_hue(84.00, 0.00);
173        grad.insert_saturation(84.00, 100.00);
174        grad.insert_brightness(84.00, 52.16);
175        grad.insert_hue(126.00, 0.00);
176        grad.insert_saturation(126.00, 100.00);
177        grad.insert_brightness(126.00, 78.04);
178        grad.insert_hue(168.00, 2.59);
179        grad.insert_saturation(168.00, 100.00);
180        grad.insert_brightness(168.00, 100.00);
181        grad.insert_hue(210.00, 18.12);
182        grad.insert_saturation(210.00, 100.00);
183        grad.insert_brightness(210.00, 100.00);
184        grad.insert_hue(252.00, 33.65);
185        grad.insert_saturation(252.00, 100.00);
186        grad.insert_brightness(252.00, 100.00);
187        grad.insert_hue(294.00, 49.41);
188        grad.insert_saturation(294.00, 100.00);
189        grad.insert_brightness(294.00, 100.00);
190        grad.insert_hue(336.00, 60.00);
191        grad.insert_saturation(336.00, 87.45);
192        grad.insert_brightness(336.00, 100.00);
193        grad.insert_hue(378.00, 60.00);
194        grad.insert_saturation(378.00, 48.63);
195        grad.insert_brightness(378.00, 100.00);
196        grad.insert_hue(420.00, 60.00);
197        grad.insert_saturation(420.00, 9.41);
198        grad.insert_brightness(420.00, 100.00);
199        grad.rescale(min, max);
200        grad
201    }
202    /// Cool color map in HSV color space.
203    /// - step:
204    /// ![cool-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/cool-step.png)
205    /// - linear:
206    /// ![cool-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/cool-linear.png)
207    pub fn cool(min: f32, max: f32) -> HsvGradient {
208        let mut grad = HsvGradient::new(0.0, 430.00);
209        grad.insert_hue(0.00, 180.00);
210        grad.insert_saturation(0.00, 100.00);
211        grad.insert_brightness(0.00, 100.00);
212        grad.insert_hue(43.00, 186.52);
213        grad.insert_saturation(43.00, 90.20);
214        grad.insert_brightness(43.00, 100.00);
215        grad.insert_hue(86.00, 194.63);
216        grad.insert_saturation(86.00, 80.39);
217        grad.insert_brightness(86.00, 100.00);
218        grad.insert_hue(129.00, 205.47);
219        grad.insert_saturation(129.00, 70.20);
220        grad.insert_brightness(129.00, 100.00);
221        grad.insert_hue(172.00, 220.00);
222        grad.insert_saturation(172.00, 60.00);
223        grad.insert_brightness(172.00, 100.00);
224        grad.insert_hue(215.00, 239.53);
225        grad.insert_saturation(215.00, 50.20);
226        grad.insert_brightness(215.00, 100.00);
227        grad.insert_hue(258.00, 260.00);
228        grad.insert_saturation(258.00, 60.00);
229        grad.insert_brightness(258.00, 100.00);
230        grad.insert_hue(301.00, 274.04);
231        grad.insert_saturation(301.00, 69.80);
232        grad.insert_brightness(301.00, 100.00);
233        grad.insert_hue(344.00, 285.00);
234        grad.insert_saturation(344.00, 80.00);
235        grad.insert_brightness(344.00, 100.00);
236        grad.insert_hue(387.00, 293.48);
237        grad.insert_saturation(387.00, 90.20);
238        grad.insert_brightness(387.00, 100.00);
239        grad.insert_hue(430.00, 300.00);
240        grad.insert_saturation(430.00, 100.00);
241        grad.insert_brightness(430.00, 100.00);
242        grad.rescale(min, max);
243        grad
244    }
245    /// Spring color map in HSV color space.
246    /// - step:
247    /// ![spring-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/spring-step.png)
248    /// - linear:
249    /// ![spring-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/spring-linear.png)
250    pub fn spring(min: f32, max: f32) -> HsvGradient {
251        let mut grad = HsvGradient::new(0.0, 430.00);
252        grad.insert_hue(0.00, -60.00);
253        grad.insert_saturation(0.00, 100.00);
254        grad.insert_brightness(0.00, 100.00);
255        grad.insert_hue(43.00, -53.48);
256        grad.insert_saturation(43.00, 90.20);
257        grad.insert_brightness(43.00, 100.00);
258        grad.insert_hue(86.00, -45.37);
259        grad.insert_saturation(86.00, 80.39);
260        grad.insert_brightness(86.00, 100.00);
261        grad.insert_hue(129.00, -34.53);
262        grad.insert_saturation(129.00, 70.20);
263        grad.insert_brightness(129.00, 100.00);
264        grad.insert_hue(172.00, -20.00);
265        grad.insert_saturation(172.00, 60.00);
266        grad.insert_brightness(172.00, 100.00);
267        grad.insert_hue(215.00, -0.47);
268        grad.insert_saturation(215.00, 50.20);
269        grad.insert_brightness(215.00, 100.00);
270        grad.insert_hue(258.00, 20.00);
271        grad.insert_saturation(258.00, 60.00);
272        grad.insert_brightness(258.00, 100.00);
273        grad.insert_hue(301.00, 34.04);
274        grad.insert_saturation(301.00, 69.80);
275        grad.insert_brightness(301.00, 100.00);
276        grad.insert_hue(344.00, 45.00);
277        grad.insert_saturation(344.00, 80.00);
278        grad.insert_brightness(344.00, 100.00);
279        grad.insert_hue(387.00, 53.48);
280        grad.insert_saturation(387.00, 90.20);
281        grad.insert_brightness(387.00, 100.00);
282        grad.insert_hue(430.00, 60.00);
283        grad.insert_saturation(430.00, 100.00);
284        grad.insert_brightness(430.00, 100.00);
285        grad.rescale(min, max);
286        grad
287    }
288    /// Summer color map in HSV color space.
289    /// - step:
290    /// ![summer-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/summer-step.png)
291    /// - linear:
292    /// ![summer-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/summer-linear.png)
293    pub fn summer(min: f32, max: f32) -> HsvGradient {
294        let mut grad = HsvGradient::new(0.0, 430.00);
295        grad.insert_hue(0.00, 167.81);
296        grad.insert_saturation(0.00, 100.00);
297        grad.insert_brightness(0.00, 50.20);
298        grad.insert_hue(43.00, 160.17);
299        grad.insert_saturation(43.00, 82.14);
300        grad.insert_brightness(43.00, 54.90);
301        grad.insert_hue(86.00, 150.29);
302        grad.insert_saturation(86.00, 67.32);
303        grad.insert_brightness(86.00, 60.00);
304        grad.insert_hue(129.00, 137.33);
305        grad.insert_saturation(129.00, 54.22);
306        grad.insert_brightness(129.00, 65.10);
307        grad.insert_hue(172.00, 120.00);
308        grad.insert_saturation(172.00, 43.02);
309        grad.insert_brightness(172.00, 70.20);
310        grad.insert_hue(215.00, 103.15);
311        grad.insert_saturation(215.00, 46.60);
312        grad.insert_brightness(215.00, 74.90);
313        grad.insert_hue(258.00, 90.00);
314        grad.insert_saturation(258.00, 50.00);
315        grad.insert_brightness(258.00, 80.00);
316        grad.insert_hue(301.00, 80.35);
317        grad.insert_saturation(301.00, 53.00);
318        grad.insert_brightness(301.00, 85.10);
319        grad.insert_hue(344.00, 72.19);
320        grad.insert_saturation(344.00, 55.65);
321        grad.insert_brightness(344.00, 90.20);
322        grad.insert_hue(387.00, 65.53);
323        grad.insert_saturation(387.00, 58.02);
324        grad.insert_brightness(387.00, 95.29);
325        grad.insert_hue(430.00, 60.00);
326        grad.insert_saturation(430.00, 60.00);
327        grad.insert_brightness(430.00, 100.00);
328        grad.rescale(min, max);
329        grad
330    }
331    /// Autumn color map in HSV color space.
332    /// - step:
333    /// ![autumn-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/autumn-step.png)
334    /// - linear:
335    /// ![autumn-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/autumn-linear.png)
336    pub fn autumn(min: f32, max: f32) -> HsvGradient {
337        let mut grad = HsvGradient::new(0.0, 430.00);
338        grad.insert_hue(0.00, 0.00);
339        grad.insert_saturation(0.00, 100.00);
340        grad.insert_brightness(0.00, 100.00);
341        grad.insert_hue(43.00, 5.88);
342        grad.insert_saturation(43.00, 100.00);
343        grad.insert_brightness(43.00, 100.00);
344        grad.insert_hue(86.00, 11.76);
345        grad.insert_saturation(86.00, 100.00);
346        grad.insert_brightness(86.00, 100.00);
347        grad.insert_hue(129.00, 17.88);
348        grad.insert_saturation(129.00, 100.00);
349        grad.insert_brightness(129.00, 100.00);
350        grad.insert_hue(172.00, 24.00);
351        grad.insert_saturation(172.00, 100.00);
352        grad.insert_brightness(172.00, 100.00);
353        grad.insert_hue(215.00, 29.88);
354        grad.insert_saturation(215.00, 100.00);
355        grad.insert_brightness(215.00, 100.00);
356        grad.insert_hue(258.00, 36.00);
357        grad.insert_saturation(258.00, 100.00);
358        grad.insert_brightness(258.00, 100.00);
359        grad.insert_hue(301.00, 41.88);
360        grad.insert_saturation(301.00, 100.00);
361        grad.insert_brightness(301.00, 100.00);
362        grad.insert_hue(344.00, 48.00);
363        grad.insert_saturation(344.00, 100.00);
364        grad.insert_brightness(344.00, 100.00);
365        grad.insert_hue(387.00, 54.12);
366        grad.insert_saturation(387.00, 100.00);
367        grad.insert_brightness(387.00, 100.00);
368        grad.insert_hue(430.00, 60.00);
369        grad.insert_saturation(430.00, 100.00);
370        grad.insert_brightness(430.00, 100.00);
371        grad.rescale(min, max);
372        grad
373    }
374    /// Winter color map in HSV color space.
375    /// - step:
376    /// ![winter-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/winter-step.png)
377    /// - linear:
378    /// ![winter-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/winter-linear.png)
379    pub fn winter(min: f32, max: f32) -> HsvGradient {
380        let mut grad = HsvGradient::new(0.0, 430.00);
381        grad.insert_hue(0.00, 240.00);
382        grad.insert_saturation(0.00, 100.00);
383        grad.insert_brightness(0.00, 100.00);
384        grad.insert_hue(43.00, 233.83);
385        grad.insert_saturation(43.00, 100.00);
386        grad.insert_brightness(43.00, 95.29);
387        grad.insert_hue(86.00, 226.96);
388        grad.insert_saturation(86.00, 100.00);
389        grad.insert_brightness(86.00, 90.20);
390        grad.insert_hue(129.00, 218.99);
391        grad.insert_saturation(129.00, 100.00);
392        grad.insert_brightness(129.00, 85.10);
393        grad.insert_hue(172.00, 210.00);
394        grad.insert_saturation(172.00, 100.00);
395        grad.insert_brightness(172.00, 80.00);
396        grad.insert_hue(215.00, 200.31);
397        grad.insert_saturation(215.00, 100.00);
398        grad.insert_brightness(215.00, 75.29);
399        grad.insert_hue(258.00, 188.72);
400        grad.insert_saturation(258.00, 100.00);
401        grad.insert_brightness(258.00, 70.20);
402        grad.insert_hue(301.00, 175.96);
403        grad.insert_saturation(301.00, 100.00);
404        grad.insert_brightness(301.00, 69.80);
405        grad.insert_hue(344.00, 165.00);
406        grad.insert_saturation(344.00, 100.00);
407        grad.insert_brightness(344.00, 80.00);
408        grad.insert_hue(387.00, 156.52);
409        grad.insert_saturation(387.00, 100.00);
410        grad.insert_brightness(387.00, 90.20);
411        grad.insert_hue(430.00, 150.12);
412        grad.insert_saturation(430.00, 100.00);
413        grad.insert_brightness(430.00, 100.00);
414        grad.rescale(min, max);
415        grad
416    }
417}