1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
use super::*;

impl Default for HsvGradient {
    fn default() -> Self {
        HsvGradient::standard(0.0, 1.0)
    }
}

/// standard hsv color maps
impl HsvGradient {
    /// Standard color map in HSV color space.
    /// - step: ![standard-step.png](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/standard-step.png)
    /// - linear: ![standard-linear.png](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/standard-linear.png)
    pub fn standard(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 360.0);
        grad.insert_hue(0.0, 0.0);
        grad.insert_hue(60.0, 60.0);
        grad.insert_hue(120.0, 120.0);
        grad.insert_hue(180.0, 180.0);
        grad.insert_hue(240.0, 240.0);
        grad.insert_hue(300.0, 300.0);
        grad.insert_hue(360.0, 360.0);
        grad.rescale(min, max);
        grad
    }
}

/// matlab color maps
impl HsvGradient {
    /// Parula color map in HSV color space.
    /// - step:
    /// ![parula-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/parula-step.png)
    /// - linear:
    /// ![parula-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/parula-linear.png)
    pub fn parula(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, 251.08);
        grad.insert_saturation(0.00, 77.38);
        grad.insert_brightness(0.00, 65.88);
        grad.insert_hue(43.00, 241.83);
        grad.insert_saturation(43.00, 71.30);
        grad.insert_brightness(43.00, 90.20);
        grad.insert_hue(86.00, 229.30);
        grad.insert_saturation(86.00, 73.12);
        grad.insert_brightness(86.00, 99.22);
        grad.insert_hue(129.00, 211.66);
        grad.insert_saturation(129.00, 81.56);
        grad.insert_brightness(129.00, 95.69);
        grad.insert_hue(172.00, 196.31);
        grad.insert_saturation(172.00, 87.44);
        grad.insert_brightness(172.00, 87.45);
        grad.insert_hue(215.00, 178.62);
        grad.insert_saturation(215.00, 91.58);
        grad.insert_brightness(215.00, 74.51);
        grad.insert_hue(258.00, 148.40);
        grad.insert_saturation(258.00, 64.53);
        grad.insert_brightness(258.00, 79.61);
        grad.insert_hue(301.00, 79.70);
        grad.insert_saturation(301.00, 66.67);
        grad.insert_brightness(301.00, 78.82);
        grad.insert_hue(344.00, 44.52);
        grad.insert_saturation(344.00, 79.49);
        grad.insert_brightness(344.00, 91.76);
        grad.insert_hue(387.00, 49.12);
        grad.insert_saturation(387.00, 81.60);
        grad.insert_brightness(387.00, 98.04);
        grad.insert_hue(430.00, 60.52);
        grad.insert_saturation(430.00, 91.63);
        grad.insert_brightness(430.00, 98.43);
        grad.rescale(min, max);
        grad
    }
    /// Jet color map in HSV color space.
    /// - step:
    /// ![jet-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/jet-step.png)
    /// - linear:
    /// ![jet-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/jet-linear.png)
    pub fn jet(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, 240.00);
        grad.insert_saturation(0.00, 100.00);
        grad.insert_brightness(0.00, 51.37);
        grad.insert_hue(43.00, 240.00);
        grad.insert_saturation(43.00, 100.00);
        grad.insert_brightness(43.00, 90.59);
        grad.insert_hue(86.00, 222.12);
        grad.insert_saturation(86.00, 100.00);
        grad.insert_brightness(86.00, 100.00);
        grad.insert_hue(129.00, 197.88);
        grad.insert_saturation(129.00, 100.00);
        grad.insert_brightness(129.00, 100.00);
        grad.insert_hue(172.00, 172.60);
        grad.insert_saturation(172.00, 89.02);
        grad.insert_brightness(172.00, 100.00);
        grad.insert_hue(215.00, 120.00);
        grad.insert_saturation(215.00, 49.80);
        grad.insert_brightness(215.00, 100.00);
        grad.insert_hue(258.00, 66.23);
        grad.insert_saturation(258.00, 90.59);
        grad.insert_brightness(258.00, 100.00);
        grad.insert_hue(301.00, 42.12);
        grad.insert_saturation(301.00, 100.00);
        grad.insert_brightness(301.00, 100.00);
        grad.insert_hue(344.00, 17.88);
        grad.insert_saturation(344.00, 100.00);
        grad.insert_brightness(344.00, 100.00);
        grad.insert_hue(387.00, 0.00);
        grad.insert_saturation(387.00, 100.00);
        grad.insert_brightness(387.00, 89.02);
        grad.insert_hue(430.00, 0.00);
        grad.insert_saturation(430.00, 100.00);
        grad.insert_brightness(430.00, 50.20);
        grad.rescale(min, max);
        grad
    }
    /// Turbo color map in HSV color space.
    /// - step:
    /// ![turbo-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/turbo-step.png)
    /// - linear:
    /// ![turbo-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/turbo-linear.png)
    pub fn turbo(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, 283.90);
        grad.insert_saturation(0.00, 69.49);
        grad.insert_brightness(0.00, 23.14);
        grad.insert_hue(43.00, 231.04);
        grad.insert_saturation(43.00, 66.01);
        grad.insert_brightness(43.00, 79.61);
        grad.insert_hue(86.00, 212.04);
        grad.insert_saturation(86.00, 74.90);
        grad.insert_brightness(86.00, 100.00);
        grad.insert_hue(129.00, 177.45);
        grad.insert_saturation(129.00, 88.26);
        grad.insert_brightness(129.00, 83.53);
        grad.insert_hue(172.00, 140.90);
        grad.insert_saturation(172.00, 71.77);
        grad.insert_brightness(172.00, 97.25);
        grad.insert_hue(215.00, 88.75);
        grad.insert_saturation(215.00, 75.89);
        grad.insert_brightness(215.00, 99.22);
        grad.insert_hue(258.00, 58.59);
        grad.insert_saturation(258.00, 75.56);
        grad.insert_brightness(258.00, 88.24);
        grad.insert_hue(301.00, 34.41);
        grad.insert_saturation(301.00, 80.31);
        grad.insert_brightness(301.00, 99.61);
        grad.insert_hue(344.00, 19.73);
        grad.insert_saturation(344.00, 92.50);
        grad.insert_brightness(344.00, 94.12);
        grad.insert_hue(387.00, 10.63);
        grad.insert_saturation(387.00, 98.46);
        grad.insert_brightness(387.00, 76.47);
        grad.insert_hue(430.00, 0.50);
        grad.insert_saturation(430.00, 97.54);
        grad.insert_brightness(430.00, 47.84);
        grad.rescale(min, max);
        grad
    }
    /// Hot color map in HSV color space.
    /// - step:
    /// ![hot-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/hot-step.png)
    /// - linear:
    /// ![hot-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/hot-linear.png)
    pub fn hot(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 420.00);
        grad.insert_hue(0.00, 0.00);
        grad.insert_saturation(0.00, 100.00);
        grad.insert_brightness(0.00, 1.18);
        grad.insert_hue(42.00, 0.00);
        grad.insert_saturation(42.00, 100.00);
        grad.insert_brightness(42.00, 25.88);
        grad.insert_hue(84.00, 0.00);
        grad.insert_saturation(84.00, 100.00);
        grad.insert_brightness(84.00, 52.16);
        grad.insert_hue(126.00, 0.00);
        grad.insert_saturation(126.00, 100.00);
        grad.insert_brightness(126.00, 78.04);
        grad.insert_hue(168.00, 2.59);
        grad.insert_saturation(168.00, 100.00);
        grad.insert_brightness(168.00, 100.00);
        grad.insert_hue(210.00, 18.12);
        grad.insert_saturation(210.00, 100.00);
        grad.insert_brightness(210.00, 100.00);
        grad.insert_hue(252.00, 33.65);
        grad.insert_saturation(252.00, 100.00);
        grad.insert_brightness(252.00, 100.00);
        grad.insert_hue(294.00, 49.41);
        grad.insert_saturation(294.00, 100.00);
        grad.insert_brightness(294.00, 100.00);
        grad.insert_hue(336.00, 60.00);
        grad.insert_saturation(336.00, 87.45);
        grad.insert_brightness(336.00, 100.00);
        grad.insert_hue(378.00, 60.00);
        grad.insert_saturation(378.00, 48.63);
        grad.insert_brightness(378.00, 100.00);
        grad.insert_hue(420.00, 60.00);
        grad.insert_saturation(420.00, 9.41);
        grad.insert_brightness(420.00, 100.00);
        grad.rescale(min, max);
        grad
    }
    /// Cool color map in HSV color space.
    /// - step:
    /// ![cool-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/cool-step.png)
    /// - linear:
    /// ![cool-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/cool-linear.png)
    pub fn cool(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, 180.00);
        grad.insert_saturation(0.00, 100.00);
        grad.insert_brightness(0.00, 100.00);
        grad.insert_hue(43.00, 186.52);
        grad.insert_saturation(43.00, 90.20);
        grad.insert_brightness(43.00, 100.00);
        grad.insert_hue(86.00, 194.63);
        grad.insert_saturation(86.00, 80.39);
        grad.insert_brightness(86.00, 100.00);
        grad.insert_hue(129.00, 205.47);
        grad.insert_saturation(129.00, 70.20);
        grad.insert_brightness(129.00, 100.00);
        grad.insert_hue(172.00, 220.00);
        grad.insert_saturation(172.00, 60.00);
        grad.insert_brightness(172.00, 100.00);
        grad.insert_hue(215.00, 239.53);
        grad.insert_saturation(215.00, 50.20);
        grad.insert_brightness(215.00, 100.00);
        grad.insert_hue(258.00, 260.00);
        grad.insert_saturation(258.00, 60.00);
        grad.insert_brightness(258.00, 100.00);
        grad.insert_hue(301.00, 274.04);
        grad.insert_saturation(301.00, 69.80);
        grad.insert_brightness(301.00, 100.00);
        grad.insert_hue(344.00, 285.00);
        grad.insert_saturation(344.00, 80.00);
        grad.insert_brightness(344.00, 100.00);
        grad.insert_hue(387.00, 293.48);
        grad.insert_saturation(387.00, 90.20);
        grad.insert_brightness(387.00, 100.00);
        grad.insert_hue(430.00, 300.00);
        grad.insert_saturation(430.00, 100.00);
        grad.insert_brightness(430.00, 100.00);
        grad.rescale(min, max);
        grad
    }
    /// Spring color map in HSV color space.
    /// - step:
    /// ![spring-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/spring-step.png)
    /// - linear:
    /// ![spring-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/spring-linear.png)
    pub fn spring(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, -60.00);
        grad.insert_saturation(0.00, 100.00);
        grad.insert_brightness(0.00, 100.00);
        grad.insert_hue(43.00, -53.48);
        grad.insert_saturation(43.00, 90.20);
        grad.insert_brightness(43.00, 100.00);
        grad.insert_hue(86.00, -45.37);
        grad.insert_saturation(86.00, 80.39);
        grad.insert_brightness(86.00, 100.00);
        grad.insert_hue(129.00, -34.53);
        grad.insert_saturation(129.00, 70.20);
        grad.insert_brightness(129.00, 100.00);
        grad.insert_hue(172.00, -20.00);
        grad.insert_saturation(172.00, 60.00);
        grad.insert_brightness(172.00, 100.00);
        grad.insert_hue(215.00, -0.47);
        grad.insert_saturation(215.00, 50.20);
        grad.insert_brightness(215.00, 100.00);
        grad.insert_hue(258.00, 20.00);
        grad.insert_saturation(258.00, 60.00);
        grad.insert_brightness(258.00, 100.00);
        grad.insert_hue(301.00, 34.04);
        grad.insert_saturation(301.00, 69.80);
        grad.insert_brightness(301.00, 100.00);
        grad.insert_hue(344.00, 45.00);
        grad.insert_saturation(344.00, 80.00);
        grad.insert_brightness(344.00, 100.00);
        grad.insert_hue(387.00, 53.48);
        grad.insert_saturation(387.00, 90.20);
        grad.insert_brightness(387.00, 100.00);
        grad.insert_hue(430.00, 60.00);
        grad.insert_saturation(430.00, 100.00);
        grad.insert_brightness(430.00, 100.00);
        grad.rescale(min, max);
        grad
    }
    /// Summer color map in HSV color space.
    /// - step:
    /// ![summer-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/summer-step.png)
    /// - linear:
    /// ![summer-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/summer-linear.png)
    pub fn summer(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, 167.81);
        grad.insert_saturation(0.00, 100.00);
        grad.insert_brightness(0.00, 50.20);
        grad.insert_hue(43.00, 160.17);
        grad.insert_saturation(43.00, 82.14);
        grad.insert_brightness(43.00, 54.90);
        grad.insert_hue(86.00, 150.29);
        grad.insert_saturation(86.00, 67.32);
        grad.insert_brightness(86.00, 60.00);
        grad.insert_hue(129.00, 137.33);
        grad.insert_saturation(129.00, 54.22);
        grad.insert_brightness(129.00, 65.10);
        grad.insert_hue(172.00, 120.00);
        grad.insert_saturation(172.00, 43.02);
        grad.insert_brightness(172.00, 70.20);
        grad.insert_hue(215.00, 103.15);
        grad.insert_saturation(215.00, 46.60);
        grad.insert_brightness(215.00, 74.90);
        grad.insert_hue(258.00, 90.00);
        grad.insert_saturation(258.00, 50.00);
        grad.insert_brightness(258.00, 80.00);
        grad.insert_hue(301.00, 80.35);
        grad.insert_saturation(301.00, 53.00);
        grad.insert_brightness(301.00, 85.10);
        grad.insert_hue(344.00, 72.19);
        grad.insert_saturation(344.00, 55.65);
        grad.insert_brightness(344.00, 90.20);
        grad.insert_hue(387.00, 65.53);
        grad.insert_saturation(387.00, 58.02);
        grad.insert_brightness(387.00, 95.29);
        grad.insert_hue(430.00, 60.00);
        grad.insert_saturation(430.00, 60.00);
        grad.insert_brightness(430.00, 100.00);
        grad.rescale(min, max);
        grad
    }
    /// Autumn color map in HSV color space.
    /// - step:
    /// ![autumn-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/autumn-step.png)
    /// - linear:
    /// ![autumn-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/autumn-linear.png)
    pub fn autumn(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, 0.00);
        grad.insert_saturation(0.00, 100.00);
        grad.insert_brightness(0.00, 100.00);
        grad.insert_hue(43.00, 5.88);
        grad.insert_saturation(43.00, 100.00);
        grad.insert_brightness(43.00, 100.00);
        grad.insert_hue(86.00, 11.76);
        grad.insert_saturation(86.00, 100.00);
        grad.insert_brightness(86.00, 100.00);
        grad.insert_hue(129.00, 17.88);
        grad.insert_saturation(129.00, 100.00);
        grad.insert_brightness(129.00, 100.00);
        grad.insert_hue(172.00, 24.00);
        grad.insert_saturation(172.00, 100.00);
        grad.insert_brightness(172.00, 100.00);
        grad.insert_hue(215.00, 29.88);
        grad.insert_saturation(215.00, 100.00);
        grad.insert_brightness(215.00, 100.00);
        grad.insert_hue(258.00, 36.00);
        grad.insert_saturation(258.00, 100.00);
        grad.insert_brightness(258.00, 100.00);
        grad.insert_hue(301.00, 41.88);
        grad.insert_saturation(301.00, 100.00);
        grad.insert_brightness(301.00, 100.00);
        grad.insert_hue(344.00, 48.00);
        grad.insert_saturation(344.00, 100.00);
        grad.insert_brightness(344.00, 100.00);
        grad.insert_hue(387.00, 54.12);
        grad.insert_saturation(387.00, 100.00);
        grad.insert_brightness(387.00, 100.00);
        grad.insert_hue(430.00, 60.00);
        grad.insert_saturation(430.00, 100.00);
        grad.insert_brightness(430.00, 100.00);
        grad.rescale(min, max);
        grad
    }
    /// Winter color map in HSV color space.
    /// - step:
    /// ![winter-step](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/winter-step.png)
    /// - linear:
    /// ![winter-linear](https://raw.githubusercontent.com/oovm/color-rs/dev/projects/color-gradient/assets/hsv/winter-linear.png)
    pub fn winter(min: f32, max: f32) -> HsvGradient {
        let mut grad = HsvGradient::new(0.0, 430.00);
        grad.insert_hue(0.00, 240.00);
        grad.insert_saturation(0.00, 100.00);
        grad.insert_brightness(0.00, 100.00);
        grad.insert_hue(43.00, 233.83);
        grad.insert_saturation(43.00, 100.00);
        grad.insert_brightness(43.00, 95.29);
        grad.insert_hue(86.00, 226.96);
        grad.insert_saturation(86.00, 100.00);
        grad.insert_brightness(86.00, 90.20);
        grad.insert_hue(129.00, 218.99);
        grad.insert_saturation(129.00, 100.00);
        grad.insert_brightness(129.00, 85.10);
        grad.insert_hue(172.00, 210.00);
        grad.insert_saturation(172.00, 100.00);
        grad.insert_brightness(172.00, 80.00);
        grad.insert_hue(215.00, 200.31);
        grad.insert_saturation(215.00, 100.00);
        grad.insert_brightness(215.00, 75.29);
        grad.insert_hue(258.00, 188.72);
        grad.insert_saturation(258.00, 100.00);
        grad.insert_brightness(258.00, 70.20);
        grad.insert_hue(301.00, 175.96);
        grad.insert_saturation(301.00, 100.00);
        grad.insert_brightness(301.00, 69.80);
        grad.insert_hue(344.00, 165.00);
        grad.insert_saturation(344.00, 100.00);
        grad.insert_brightness(344.00, 80.00);
        grad.insert_hue(387.00, 156.52);
        grad.insert_saturation(387.00, 100.00);
        grad.insert_brightness(387.00, 90.20);
        grad.insert_hue(430.00, 150.12);
        grad.insert_saturation(430.00, 100.00);
        grad.insert_brightness(430.00, 100.00);
        grad.rescale(min, max);
        grad
    }
}