49 {
50
51struct Vector4;
52
54
55
56
58
59
74
75
76
77
93
96};
97
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116struct ColorMatrix {
118};
119
120
121
122
123struct Color {
124
125
126
128
129
130
131
133
134
135
136
138
139
140
141
143
144 constexpr Color() {}
145
146 explicit Color(const Vector4& value);
147
148 constexpr Color(Scalar r, Scalar g, Scalar b, Scalar a)
149 : red(r), green(g), blue(
b), alpha(a) {}
150
151 static constexpr Color MakeRGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
152 return Color(
153 static_cast<Scalar>(r) / 255.0f,
static_cast<Scalar>(g) / 255.0f,
154 static_cast<Scalar>(b) / 255.0f,
static_cast<Scalar>(a) / 255.0f);
155 }
156
157
158 static inline uint32_t ToIColor(Color color) {
159 return (((std::lround(color.alpha * 255.0f) & 0xff) << 24) |
160 ((std::lround(color.red * 255.0f) & 0xff) << 16) |
161 ((std::lround(color.green * 255.0f) & 0xff) << 8) |
162 ((std::lround(color.blue * 255.0f) & 0xff) << 0)) &
163 0xFFFFFFFF;
164 }
165
166 constexpr inline bool operator==(
const Color&
c)
const {
169 }
170
171 constexpr inline Color
operator+(
const Color&
c)
const {
172 return {red +
c.
red, green +
c.green, blue +
c.blue, alpha +
c.alpha};
173 }
174
175 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
176 constexpr inline Color
operator+(T value)
const {
178 return {red + v, green + v, blue + v, alpha + v};
179 }
180
181 constexpr inline Color
operator-(
const Color&
c)
const {
182 return {red -
c.
red, green -
c.green, blue -
c.blue, alpha -
c.alpha};
183 }
184
185 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
186 constexpr inline Color
operator-(T value)
const {
188 return {red - v, green - v, blue - v, alpha - v};
189 }
190
191 constexpr inline Color
operator*(
const Color&
c)
const {
192 return {red *
c.
red, green *
c.green, blue *
c.blue, alpha *
c.alpha};
193 }
194
195 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
196 constexpr inline Color
operator*(T value)
const {
198 return {red * v, green * v, blue * v, alpha * v};
199 }
200
201 constexpr inline Color
operator/(
const Color&
c)
const {
202 return {red *
c.
red, green *
c.green, blue *
c.blue, alpha *
c.alpha};
203 }
204
205 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
206 constexpr inline Color
operator/(T value)
const {
208 return {red / v, green / v, blue / v, alpha / v};
209 }
210
211 constexpr Color Premultiply() const {
212 return {red * alpha, green * alpha, blue * alpha, alpha};
213 }
214
215 constexpr Color Unpremultiply() const {
217 return Color::BlackTransparent();
218 }
219 return {red / alpha, green / alpha, blue / alpha, alpha};
220 }
221
222
223
224
225
226
227
228
229
230
231 constexpr static Color Lerp(Color a, Color b, Scalar t) {
232 return a + (
b - a) * t;
233 }
234
235 constexpr Color Clamp01() const {
236 return Color(std::clamp(red, 0.0f, 1.0f), std::clamp(green, 0.0f, 1.0f),
237 std::clamp(blue, 0.0f, 1.0f), std::clamp(alpha, 0.0f, 1.0f));
238 }
239
240
241
242
243
244
245 inline std::array<uint8_t, 4> ToR8G8B8A8() const {
246 uint8_t r = std::round(red * 255.0f);
247 uint8_t g = std::round(green * 255.0f);
248 uint8_t
b = std::round(blue * 255.0f);
249 uint8_t a = std::round(alpha * 255.0f);
251 }
252
253
254
255
256
257
258 inline uint32_t ToARGB() const {
259 std::array<uint8_t, 4> result = ToR8G8B8A8();
260 return result[3] << 24 | result[0] << 16 | result[1] << 8 | result[2];
261 }
262
263 template <typename H>
264 friend H AbslHashValue(H h,
const Color&
c) {
265 return H::combine(std::move(h),
c.ToARGB());
266 }
267
268 static constexpr Color White() { return {1.0f, 1.0f, 1.0f, 1.0f}; }
269
270 static constexpr Color Black() { return {0.0f, 0.0f, 0.0f, 1.0f}; }
271
272 static constexpr Color WhiteTransparent() { return {1.0f, 1.0f, 1.0f, 0.0f}; }
273
274 static constexpr Color BlackTransparent() { return {0.0f, 0.0f, 0.0f, 0.0f}; }
275
276 static constexpr Color Red() { return {1.0f, 0.0f, 0.0f, 1.0f}; }
277
278 static constexpr Color Green() { return {0.0f, 1.0f, 0.0f, 1.0f}; }
279
280 static constexpr Color Blue() { return {0.0f, 0.0f, 1.0f, 1.0f}; }
281
282 constexpr Color WithAlpha(Scalar new_alpha) const {
283 return {red, green, blue, new_alpha};
284 }
285
286 static constexpr Color AliceBlue() {
287 return {240.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
288 }
289
290 static constexpr Color AntiqueWhite() {
291 return {250.0f / 255.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f};
292 }
293
294 static constexpr Color Aqua() {
295 return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
296 }
297
298 static constexpr Color AquaMarine() {
299 return {127.0f / 255.0f, 255.0f / 255.0f, 212.0f / 255.0f, 1.0f};
300 }
301
302 static constexpr Color Azure() {
303 return {240.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
304 }
305
306 static constexpr Color Beige() {
307 return {245.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f, 1.0f};
308 }
309
310 static constexpr Color Bisque() {
311 return {255.0f / 255.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f};
312 }
313
314 static constexpr Color BlanchedAlmond() {
315 return {255.0f / 255.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f};
316 }
317
318 static constexpr Color BlueViolet() {
319 return {138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f};
320 }
321
322 static constexpr Color Brown() {
323 return {165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f};
324 }
325
326 static constexpr Color BurlyWood() {
327 return {222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f};
328 }
329
330 static constexpr Color CadetBlue() {
331 return {95.0f / 255.0f, 158.0f / 255.0f, 160.0f / 255.0f, 1.0f};
332 }
333
334 static constexpr Color Chartreuse() {
335 return {127.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
336 }
337
338 static constexpr Color Chocolate() {
339 return {210.0f / 255.0f, 105.0f / 255.0f, 30.0f / 255.0f, 1.0f};
340 }
341
342 static constexpr Color Coral() {
343 return {255.0f / 255.0f, 127.0f / 255.0f, 80.0f / 255.0f, 1.0f};
344 }
345
346 static constexpr Color CornflowerBlue() {
347 return {100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f};
348 }
349
350 static constexpr Color Cornsilk() {
351 return {255.0f / 255.0f, 248.0f / 255.0f, 220.0f / 255.0f, 1.0f};
352 }
353
354 static constexpr Color Crimson() {
355 return {220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f};
356 }
357
358 static constexpr Color Cyan() {
359 return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
360 }
361
362 static constexpr Color DarkBlue() {
363 return {0.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
364 }
365
366 static constexpr Color DarkCyan() {
367 return {0.0f / 255.0f, 139.0f / 255.0f, 139.0f / 255.0f, 1.0f};
368 }
369
370 static constexpr Color DarkGoldenrod() {
371 return {184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f};
372 }
373
374 static constexpr Color DarkGray() {
375 return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
376 }
377
378 static constexpr Color DarkGreen() {
379 return {0.0f / 255.0f, 100.0f / 255.0f, 0.0f / 255.0f, 1.0f};
380 }
381
382 static constexpr Color DarkGrey() {
383 return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
384 }
385
386 static constexpr Color DarkKhaki() {
387 return {189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f};
388 }
389
390 static constexpr Color DarkMagenta() {
391 return {139.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
392 }
393
394 static constexpr Color DarkOliveGreen() {
395 return {85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f};
396 }
397
398 static constexpr Color DarkOrange() {
399 return {255.0f / 255.0f, 140.0f / 255.0f, 0.0f / 255.0f, 1.0f};
400 }
401
402 static constexpr Color DarkOrchid() {
403 return {153.0f / 255.0f, 50.0f / 255.0f, 204.0f / 255.0f, 1.0f};
404 }
405
406 static constexpr Color DarkRed() {
407 return {139.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
408 }
409
410 static constexpr Color DarkSalmon() {
411 return {233.0f / 255.0f, 150.0f / 255.0f, 122.0f / 255.0f, 1.0f};
412 }
413
414 static constexpr Color DarkSeagreen() {
415 return {143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f};
416 }
417
418 static constexpr Color DarkSlateBlue() {
419 return {72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f};
420 }
421
422 static constexpr Color DarkSlateGray() {
423 return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
424 }
425
426 static constexpr Color DarkSlateGrey() {
427 return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
428 }
429
430 static constexpr Color DarkTurquoise() {
431 return {0.0f / 255.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f};
432 }
433
434 static constexpr Color DarkViolet() {
435 return {148.0f / 255.0f, 0.0f / 255.0f, 211.0f / 255.0f, 1.0f};
436 }
437
438 static constexpr Color DeepPink() {
439 return {255.0f / 255.0f, 20.0f / 255.0f, 147.0f / 255.0f, 1.0f};
440 }
441
442 static constexpr Color DeepSkyBlue() {
443 return {0.0f / 255.0f, 191.0f / 255.0f, 255.0f / 255.0f, 1.0f};
444 }
445
446 static constexpr Color DimGray() {
447 return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
448 }
449
450 static constexpr Color DimGrey() {
451 return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
452 }
453
454 static constexpr Color DodgerBlue() {
455 return {30.0f / 255.0f, 144.0f / 255.0f, 255.0f / 255.0f, 1.0f};
456 }
457
458 static constexpr Color Firebrick() {
459 return {178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f};
460 }
461
462 static constexpr Color FloralWhite() {
463 return {255.0f / 255.0f, 250.0f / 255.0f, 240.0f / 255.0f, 1.0f};
464 }
465
466 static constexpr Color ForestGreen() {
467 return {34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f};
468 }
469
470 static constexpr Color Fuchsia() {
471 return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
472 }
473
474 static constexpr Color Gainsboro() {
475 return {220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f, 1.0f};
476 }
477
478 static constexpr Color Ghostwhite() {
479 return {248.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
480 }
481
482 static constexpr Color Gold() {
483 return {255.0f / 255.0f, 215.0f / 255.0f, 0.0f / 255.0f, 1.0f};
484 }
485
486 static constexpr Color Goldenrod() {
487 return {218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f};
488 }
489
490 static constexpr Color Gray() {
491 return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
492 }
493
494 static constexpr Color GreenYellow() {
495 return {173.0f / 255.0f, 255.0f / 255.0f, 47.0f / 255.0f, 1.0f};
496 }
497
498 static constexpr Color Grey() {
499 return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
500 }
501
502 static constexpr Color Honeydew() {
503 return {240.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
504 }
505
506 static constexpr Color HotPink() {
507 return {255.0f / 255.0f, 105.0f / 255.0f, 180.0f / 255.0f, 1.0f};
508 }
509
510 static constexpr Color IndianRed() {
511 return {205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f};
512 }
513
514 static constexpr Color Indigo() {
515 return {75.0f / 255.0f, 0.0f / 255.0f, 130.0f / 255.0f, 1.0f};
516 }
517
518 static constexpr Color Ivory() {
519 return {255.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
520 }
521
522 static constexpr Color Khaki() {
523 return {240.0f / 255.0f, 230.0f / 255.0f, 140.0f / 255.0f, 1.0f};
524 }
525
526 static constexpr Color Lavender() {
527 return {230.0f / 255.0f, 230.0f / 255.0f, 250.0f / 255.0f, 1.0f};
528 }
529
530 static constexpr Color LavenderBlush() {
531 return {255.0f / 255.0f, 240.0f / 255.0f, 245.0f / 255.0f, 1.0f};
532 }
533
534 static constexpr Color LawnGreen() {
535 return {124.0f / 255.0f, 252.0f / 255.0f, 0.0f / 255.0f, 1.0f};
536 }
537
538 static constexpr Color LemonChiffon() {
539 return {255.0f / 255.0f, 250.0f / 255.0f, 205.0f / 255.0f, 1.0f};
540 }
541
542 static constexpr Color LightBlue() {
543 return {173.0f / 255.0f, 216.0f / 255.0f, 230.0f / 255.0f, 1.0f};
544 }
545
546 static constexpr Color LightCoral() {
547 return {240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
548 }
549
550 static constexpr Color LightCyan() {
551 return {224.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
552 }
553
554 static constexpr Color LightGoldenrodYellow() {
555 return {50.0f / 255.0f, 250.0f / 255.0f, 210.0f / 255.0f, 1.0f};
556 }
557
558 static constexpr Color LightGray() {
559 return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
560 }
561
562 static constexpr Color LightGreen() {
563 return {144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f};
564 }
565
566 static constexpr Color LightGrey() {
567 return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
568 }
569
570 static constexpr Color LightPink() {
571 return {255.0f / 255.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f};
572 }
573
574 static constexpr Color LightSalmon() {
575 return {255.0f / 255.0f, 160.0f / 255.0f, 122.0f / 255.0f, 1.0f};
576 }
577
578 static constexpr Color LightSeaGreen() {
579 return {32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f};
580 }
581
582 static constexpr Color LightSkyBlue() {
583 return {135.0f / 255.0f, 206.0f / 255.0f, 250.0f / 255.0f, 1.0f};
584 }
585
586 static constexpr Color LightSlateGray() {
587 return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
588 }
589
590 static constexpr Color LightSlateGrey() {
591 return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
592 }
593
594 static constexpr Color LightSteelBlue() {
595 return {176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f};
596 }
597
598 static constexpr Color LightYellow() {
599 return {255.0f / 255.0f, 255.0f / 255.0f, 224.0f / 255.0f, 1.0f};
600 }
601
602 static constexpr Color Lime() {
603 return {0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
604 }
605
606 static constexpr Color LimeGreen() {
607 return {50.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
608 }
609
610 static constexpr Color Linen() {
611 return {250.0f / 255.0f, 240.0f / 255.0f, 230.0f / 255.0f, 1.0f};
612 }
613
614 static constexpr Color Magenta() {
615 return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
616 }
617
618 static constexpr Color Maroon() {
619 return {128.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
620 }
621
622 static constexpr Color MediumAquamarine() {
623 return {102.0f / 255.0f, 205.0f / 255.0f, 170.0f / 255.0f, 1.0f};
624 }
625
626 static constexpr Color MediumBlue() {
627 return {0.0f / 255.0f, 0.0f / 255.0f, 205.0f / 255.0f, 1.0f};
628 }
629
630 static constexpr Color MediumOrchid() {
631 return {186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f};
632 }
633
634 static constexpr Color MediumPurple() {
635 return {147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f};
636 }
637
638 static constexpr Color MediumSeagreen() {
639 return {60.0f / 255.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f};
640 }
641
642 static constexpr Color MediumSlateBlue() {
643 return {123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f};
644 }
645
646 static constexpr Color MediumSpringGreen() {
647 return {0.0f / 255.0f, 250.0f / 255.0f, 154.0f / 255.0f, 1.0f};
648 }
649
650 static constexpr Color MediumTurquoise() {
651 return {72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f};
652 }
653
654 static constexpr Color MediumVioletRed() {
655 return {199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f};
656 }
657
658 static constexpr Color MidnightBlue() {
659 return {25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f};
660 }
661
662 static constexpr Color MintCream() {
663 return {245.0f / 255.0f, 255.0f / 255.0f, 250.0f / 255.0f, 1.0f};
664 }
665
666 static constexpr Color MistyRose() {
667 return {255.0f / 255.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f};
668 }
669
670 static constexpr Color Moccasin() {
671 return {255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f};
672 }
673
674 static constexpr Color NavajoWhite() {
675 return {255.0f / 255.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f};
676 }
677
678 static constexpr Color Navy() {
679 return {0.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
680 }
681
682 static constexpr Color OldLace() {
683 return {253.0f / 255.0f, 245.0f / 255.0f, 230.0f / 255.0f, 1.0f};
684 }
685
686 static constexpr Color Olive() {
687 return {128.0f / 255.0f, 128.0f / 255.0f, 0.0f / 255.0f, 1.0f};
688 }
689
690 static constexpr Color OliveDrab() {
691 return {107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f};
692 }
693
694 static constexpr Color Orange() {
695 return {255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f};
696 }
697
698 static constexpr Color OrangeRed() {
699 return {255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f};
700 }
701
702 static constexpr Color Orchid() {
703 return {218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f};
704 }
705
706 static constexpr Color PaleGoldenrod() {
707 return {238.0f / 255.0f, 232.0f / 255.0f, 170.0f / 255.0f, 1.0f};
708 }
709
710 static constexpr Color PaleGreen() {
711 return {152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f};
712 }
713
714 static constexpr Color PaleTurquoise() {
715 return {175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f};
716 }
717
718 static constexpr Color PaleVioletRed() {
719 return {219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f};
720 }
721
722 static constexpr Color PapayaWhip() {
723 return {255.0f / 255.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f};
724 }
725
726 static constexpr Color Peachpuff() {
727 return {255.0f / 255.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f};
728 }
729
730 static constexpr Color Peru() {
731 return {205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f};
732 }
733
734 static constexpr Color Pink() {
735 return {255.0f / 255.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f};
736 }
737
738 static constexpr Color Plum() {
739 return {221.0f / 255.0f, 160.0f / 255.0f, 221.0f / 255.0f, 1.0f};
740 }
741
742 static constexpr Color PowderBlue() {
743 return {176.0f / 255.0f, 224.0f / 255.0f, 230.0f / 255.0f, 1.0f};
744 }
745
746 static constexpr Color Purple() {
747 return {128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
748 }
749
750 static constexpr Color RosyBrown() {
751 return {188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f};
752 }
753
754 static constexpr Color RoyalBlue() {
755 return {65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f};
756 }
757
758 static constexpr Color SaddleBrown() {
759 return {139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f};
760 }
761
762 static constexpr Color Salmon() {
763 return {250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f};
764 }
765
766 static constexpr Color SandyBrown() {
767 return {244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f};
768 }
769
770 static constexpr Color Seagreen() {
771 return {46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f};
772 }
773
774 static constexpr Color Seashell() {
775 return {255.0f / 255.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f};
776 }
777
778 static constexpr Color Sienna() {
779 return {160.0f / 255.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f};
780 }
781
782 static constexpr Color Silver() {
783 return {192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f};
784 }
785
786 static constexpr Color SkyBlue() {
787 return {135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f};
788 }
789
790 static constexpr Color SlateBlue() {
791 return {106.0f / 255.0f, 90.0f / 255.0f, 205.0f / 255.0f, 1.0f};
792 }
793
794 static constexpr Color SlateGray() {
795 return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
796 }
797
798 static constexpr Color SlateGrey() {
799 return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
800 }
801
802 static constexpr Color Snow() {
803 return {255.0f / 255.0f, 250.0f / 255.0f, 250.0f / 255.0f, 1.0f};
804 }
805
806 static constexpr Color SpringGreen() {
807 return {0.0f / 255.0f, 255.0f / 255.0f, 127.0f / 255.0f, 1.0f};
808 }
809
810 static constexpr Color SteelBlue() {
811 return {70.0f / 255.0f, 130.0f / 255.0f, 180.0f / 255.0f, 1.0f};
812 }
813
814 static constexpr Color Tan() {
815 return {210.0f / 255.0f, 180.0f / 255.0f, 140.0f / 255.0f, 1.0f};
816 }
817
818 static constexpr Color Teal() {
819 return {0.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
820 }
821
822 static constexpr Color Thistle() {
823 return {216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f};
824 }
825
826 static constexpr Color Tomato() {
827 return {255.0f / 255.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f};
828 }
829
830 static constexpr Color Turquoise() {
831 return {64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f};
832 }
833
834 static constexpr Color Violet() {
835 return {238.0f / 255.0f, 130.0f / 255.0f, 238.0f / 255.0f, 1.0f};
836 }
837
838 static constexpr Color Wheat() {
839 return {245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f};
840 }
841
842 static constexpr Color Whitesmoke() {
843 return {245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f};
844 }
845
846 static constexpr Color Yellow() {
847 return {255.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
848 }
849
850 static constexpr Color YellowGreen() {
851 return {154.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
852 }
853
854 static Color Random() {
855 return {
856
857
858 static_cast<Scalar>((std::rand() % 255) / 255.0f),
859 static_cast<Scalar>((std::rand() % 255) / 255.0f),
860 static_cast<Scalar>((std::rand() % 255) / 255.0f),
861
862 1.0f
863
864 };
865 }
866
867
868
869
870
871
872 Color Blend(Color source, BlendMode blend_mode) const;
873
874
875
876
877
878
879
880
881
882 Color ApplyColorMatrix(const ColorMatrix& color_matrix) const;
883
884
885
886
887
888 Color LinearToSRGB() const;
889
890
891
892
893
894 Color SRGBToLinear() const;
895
896 constexpr bool IsTransparent() const { return alpha == 0.0f; }
897
898 constexpr bool IsOpaque() const { return alpha == 1.0f; }
899};
900
901template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
902constexpr inline Color
operator+(T value,
const Color&
c) {
904}
905
906template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
907constexpr inline Color
operator-(T value,
const Color&
c) {
909 return {v -
c.red, v -
c.green, v -
c.blue, v -
c.alpha};
910}
911
912template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
913constexpr inline Color
operator*(T value,
const Color&
c) {
915}
916
917template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
918constexpr inline Color
operator/(T value,
const Color&
c) {
920 return {v /
c.red, v /
c.green, v /
c.blue, v /
c.alpha};
921}
922
923static_assert(sizeof(Color) == 4 * sizeof(Scalar));
924
925}
926
928
930 out <<
"(" <<
c.red <<
", " <<
c.green <<
", " <<
c.blue <<
", " <<
c.alpha
931 << ")";
932 return out;
933}
934
935inline std::ostream&
operator<<(std::ostream& out,
938 return out;
939}
940
941}
942
943#endif
bool operator==(const FlutterPoint &a, const FlutterPoint &b)
constexpr Color operator-(T value, const Color &c)
constexpr Color operator/(T value, const Color &c)
constexpr Color operator+(T value, const Color &c)
const char * BlendModeToString(BlendMode blend_mode)
constexpr Color operator*(T value, const Color &c)
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
std::ostream & operator<<(std::ostream &out, const impeller::Arc &a)