| Flutter Impeller |

color.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #pragma once
6
7 #include <stdint.h>
8 #include <algorithm>
9 #include <array>
10 #include <cstdlib>
11 #include <ostream>
12 #include <type_traits>
13
14 #include "impeller/geometry/scalar.h"
15 #include "impeller/geometry/type_traits.h"
16
17 #define IMPELLER_FOR_EACH_BLEND_MODE(V) \
18 V(Clear) \
19 V(Source) \
20 V(Destination) \
21 V(SourceOver) \
22 V(DestinationOver) \
23 V(SourceIn) \
24 V(DestinationIn) \
25 V(SourceOut) \
26 V(DestinationOut) \
27 V(SourceATop) \
28 V(DestinationATop) \
29 V(Xor) \
30 V(Plus) \
31 V(Modulate) \
32 V(Screen) \
33 V(Overlay) \
34 V(Darken) \
35 V(Lighten) \
36 V(ColorDodge) \
37 V(ColorBurn) \
38 V(HardLight) \
39 V(SoftLight) \
40 V(Difference) \
41 V(Exclusion) \
42 V(Multiply) \
43 V(Hue) \
44 V(Saturation) \
45 V(Color) \
46 V(Luminosity)
47
48 namespace impeller {
49
50 struct ColorHSB;
51 struct Vector4;
52
53 enum class YUVColorSpace { kBT601LimitedRange, kBT601FullRange };
54
55 /// All blend modes assume that both the source (fragment output) and
56 /// destination (first color attachment) have colors with premultiplied alpha.
57 enum class BlendMode {
58 // The following blend modes are able to be used as pipeline blend modes or
59 // via `BlendFilterContents`.
60 kClear = 0,
61 kSource,
62 kDestination,
63 kSourceOver,
64 kDestinationOver,
65 kSourceIn,
66 kDestinationIn,
67 kSourceOut,
68 kDestinationOut,
69 kSourceATop,
70 kDestinationATop,
71 kXor,
72 kPlus,
73 kModulate,
74
75 // The following blend modes use equations that are not available for
76 // pipelines on most graphics devices without extensions, and so they are
77 // only able to be used via `BlendFilterContents`.
78 kScreen,
79 kOverlay,
80 kDarken,
81 kLighten,
82 kColorDodge,
83 kColorBurn,
84 kHardLight,
85 kSoftLight,
86 kDifference,
87 kExclusion,
88 kMultiply,
89 kHue,
90 kSaturation,
91 kColor,
92 kLuminosity,
93
94 kLast = kLuminosity,
95 };
96
97 const char* BlendModeToString(BlendMode blend_mode);
98
99 /// 4x5 matrix for transforming the color and alpha components of a Bitmap.
100 ///
101 /// [ a, b, c, d, e,
102 /// f, g, h, i, j,
103 /// k, l, m, n, o,
104 /// p, q, r, s, t ]
105 ///
106 /// When applied to a color [R, G, B, A], the resulting color is computed as:
107 ///
108 /// R’ = a*R + b*G + c*B + d*A + e;
109 /// G’ = f*R + g*G + h*B + i*A + j;
110 /// B’ = k*R + l*G + m*B + n*A + o;
111 /// A’ = p*R + q*G + r*B + s*A + t;
112 ///
113 /// That resulting color [R’, G’, B’, A’] then has each channel clamped to the 0
114 /// to 1 range.
115 struct ColorMatrix {
116 Scalar array[20];
117 };
118
119 /**
120 * Represents a RGBA color
121 */
122 struct Color {
123 /**
124 * The red color component (0 to 1)
125 */
126 Scalar red = 0.0;
127
128 /**
129 * The green color component (0 to 1)
130 */
131 Scalar green = 0.0;
132
133 /**
134 * The blue color component (0 to 1)
135 */
136 Scalar blue = 0.0;
137
138 /**
139 * The alpha component of the color (0 to 1)
140 */
141 Scalar alpha = 0.0;
142
143 constexpr Color() {}
144
145 explicit Color(const ColorHSB& hsbColor);
146
147 explicit Color(const Vector4& value);
148
149 constexpr Color(Scalar r, Scalar g, Scalar b, Scalar a)
150 : red(r), green(g), blue(b), alpha(a) {}
151
152 static constexpr Color MakeRGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
153 return Color(
154 static_cast<Scalar>(r) / 255.0f, static_cast<Scalar>(g) / 255.0f,
155 static_cast<Scalar>(b) / 255.0f, static_cast<Scalar>(a) / 255.0f);
156 }
157
158 /// @brief Convert this color to a 32-bit representation.
159 static constexpr uint32_t ToIColor(Color color) {
160 return (((std::lround(color.alpha * 255.0f) & 0xff) << 24) |
161 ((std::lround(color.red * 255.0f) & 0xff) << 16) |
162 ((std::lround(color.green * 255.0f) & 0xff) << 8) |
163 ((std::lround(color.blue * 255.0f) & 0xff) << 0)) &
164 0xFFFFFFFF;
165 }
166
167 constexpr inline bool operator==(const Color& c) const {
168 return ScalarNearlyEqual(red, c.red) && ScalarNearlyEqual(green, c.green) &&
169 ScalarNearlyEqual(blue, c.blue) && ScalarNearlyEqual(alpha, c.alpha);
170 }
171
172 constexpr inline Color operator+(const Color& c) const {
173 return {red + c.red, green + c.green, blue + c.blue, alpha + c.alpha};
174 }
175
176 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
177 constexpr inline Color operator+(T value) const {
178 auto v = static_cast<Scalar>(value);
179 return {red + v, green + v, blue + v, alpha + v};
180 }
181
182 constexpr inline Color operator-(const Color& c) const {
183 return {red - c.red, green - c.green, blue - c.blue, alpha - c.alpha};
184 }
185
186 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
187 constexpr inline Color operator-(T value) const {
188 auto v = static_cast<Scalar>(value);
189 return {red - v, green - v, blue - v, alpha - v};
190 }
191
192 constexpr inline Color operator*(const Color& c) const {
193 return {red * c.red, green * c.green, blue * c.blue, alpha * c.alpha};
194 }
195
196 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
197 constexpr inline Color operator*(T value) const {
198 auto v = static_cast<Scalar>(value);
199 return {red * v, green * v, blue * v, alpha * v};
200 }
201
202 constexpr inline Color operator/(const Color& c) const {
203 return {red * c.red, green * c.green, blue * c.blue, alpha * c.alpha};
204 }
205
206 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
207 constexpr inline Color operator/(T value) const {
208 auto v = static_cast<Scalar>(value);
209 return {red / v, green / v, blue / v, alpha / v};
210 }
211
212 constexpr Color Premultiply() const {
213 return {red * alpha, green * alpha, blue * alpha, alpha};
214 }
215
216 constexpr Color Unpremultiply() const {
217 if (ScalarNearlyEqual(alpha, 0.0f)) {
218 return Color::BlackTransparent();
219 }
220 return {red / alpha, green / alpha, blue / alpha, alpha};
221 }
222
223 /**
224 * @brief Return a color that is linearly interpolated between colors a
225 * and b, according to the value of t.
226 *
227 * @param a The lower color.
228 * @param b The upper color.
229 * @param t A value between 0.0f and 1.0f, inclusive.
230 * @return constexpr Color
231 */
232 constexpr static Color Lerp(Color a, Color b, Scalar t) {
233 return a + (b - a) * t;
234 }
235
236 constexpr Color Clamp01() const {
237 return Color(std::clamp(red, 0.0f, 1.0f), std::clamp(green, 0.0f, 1.0f),
238 std::clamp(blue, 0.0f, 1.0f), std::clamp(alpha, 0.0f, 1.0f));
239 }
240
241 /**
242 * @brief Convert to R8G8B8A8 representation.
243 *
244 * @return constexpr std::array<u_int8, 4>
245 */
246 constexpr std::array<uint8_t, 4> ToR8G8B8A8() const {
247 uint8_t r = std::round(red * 255.0f);
248 uint8_t g = std::round(green * 255.0f);
249 uint8_t b = std::round(blue * 255.0f);
250 uint8_t a = std::round(alpha * 255.0f);
251 return {r, g, b, a};
252 }
253
254 static constexpr Color White() { return {1.0f, 1.0f, 1.0f, 1.0f}; }
255
256 static constexpr Color Black() { return {0.0f, 0.0f, 0.0f, 1.0f}; }
257
258 static constexpr Color WhiteTransparent() { return {1.0f, 1.0f, 1.0f, 0.0f}; }
259
260 static constexpr Color BlackTransparent() { return {0.0f, 0.0f, 0.0f, 0.0f}; }
261
262 static constexpr Color Red() { return {1.0f, 0.0f, 0.0f, 1.0f}; }
263
264 static constexpr Color Green() { return {0.0f, 1.0f, 0.0f, 1.0f}; }
265
266 static constexpr Color Blue() { return {0.0f, 0.0f, 1.0f, 1.0f}; }
267
268 constexpr Color WithAlpha(Scalar new_alpha) const {
269 return {red, green, blue, new_alpha};
270 }
271
272 static constexpr Color AliceBlue() {
273 return {240.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
274 }
275
276 static constexpr Color AntiqueWhite() {
277 return {250.0f / 255.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f};
278 }
279
280 static constexpr Color Aqua() {
281 return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
282 }
283
284 static constexpr Color AquaMarine() {
285 return {127.0f / 255.0f, 255.0f / 255.0f, 212.0f / 255.0f, 1.0f};
286 }
287
288 static constexpr Color Azure() {
289 return {240.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
290 }
291
292 static constexpr Color Beige() {
293 return {245.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f, 1.0f};
294 }
295
296 static constexpr Color Bisque() {
297 return {255.0f / 255.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f};
298 }
299
300 static constexpr Color BlanchedAlmond() {
301 return {255.0f / 255.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f};
302 }
303
304 static constexpr Color BlueViolet() {
305 return {138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f};
306 }
307
308 static constexpr Color Brown() {
309 return {165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f};
310 }
311
312 static constexpr Color BurlyWood() {
313 return {222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f};
314 }
315
316 static constexpr Color CadetBlue() {
317 return {95.0f / 255.0f, 158.0f / 255.0f, 160.0f / 255.0f, 1.0f};
318 }
319
320 static constexpr Color Chartreuse() {
321 return {127.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
322 }
323
324 static constexpr Color Chocolate() {
325 return {210.0f / 255.0f, 105.0f / 255.0f, 30.0f / 255.0f, 1.0f};
326 }
327
328 static constexpr Color Coral() {
329 return {255.0f / 255.0f, 127.0f / 255.0f, 80.0f / 255.0f, 1.0f};
330 }
331
332 static constexpr Color CornflowerBlue() {
333 return {100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f};
334 }
335
336 static constexpr Color Cornsilk() {
337 return {255.0f / 255.0f, 248.0f / 255.0f, 220.0f / 255.0f, 1.0f};
338 }
339
340 static constexpr Color Crimson() {
341 return {220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f};
342 }
343
344 static constexpr Color Cyan() {
345 return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
346 }
347
348 static constexpr Color DarkBlue() {
349 return {0.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
350 }
351
352 static constexpr Color DarkCyan() {
353 return {0.0f / 255.0f, 139.0f / 255.0f, 139.0f / 255.0f, 1.0f};
354 }
355
356 static constexpr Color DarkGoldenrod() {
357 return {184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f};
358 }
359
360 static constexpr Color DarkGray() {
361 return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
362 }
363
364 static constexpr Color DarkGreen() {
365 return {0.0f / 255.0f, 100.0f / 255.0f, 0.0f / 255.0f, 1.0f};
366 }
367
368 static constexpr Color DarkGrey() {
369 return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
370 }
371
372 static constexpr Color DarkKhaki() {
373 return {189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f};
374 }
375
376 static constexpr Color DarkMagenta() {
377 return {139.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
378 }
379
380 static constexpr Color DarkOliveGreen() {
381 return {85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f};
382 }
383
384 static constexpr Color DarkOrange() {
385 return {255.0f / 255.0f, 140.0f / 255.0f, 0.0f / 255.0f, 1.0f};
386 }
387
388 static constexpr Color DarkOrchid() {
389 return {153.0f / 255.0f, 50.0f / 255.0f, 204.0f / 255.0f, 1.0f};
390 }
391
392 static constexpr Color DarkRed() {
393 return {139.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
394 }
395
396 static constexpr Color DarkSalmon() {
397 return {233.0f / 255.0f, 150.0f / 255.0f, 122.0f / 255.0f, 1.0f};
398 }
399
400 static constexpr Color DarkSeagreen() {
401 return {143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f};
402 }
403
404 static constexpr Color DarkSlateBlue() {
405 return {72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f};
406 }
407
408 static constexpr Color DarkSlateGray() {
409 return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
410 }
411
412 static constexpr Color DarkSlateGrey() {
413 return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
414 }
415
416 static constexpr Color DarkTurquoise() {
417 return {0.0f / 255.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f};
418 }
419
420 static constexpr Color DarkViolet() {
421 return {148.0f / 255.0f, 0.0f / 255.0f, 211.0f / 255.0f, 1.0f};
422 }
423
424 static constexpr Color DeepPink() {
425 return {255.0f / 255.0f, 20.0f / 255.0f, 147.0f / 255.0f, 1.0f};
426 }
427
428 static constexpr Color DeepSkyBlue() {
429 return {0.0f / 255.0f, 191.0f / 255.0f, 255.0f / 255.0f, 1.0f};
430 }
431
432 static constexpr Color DimGray() {
433 return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
434 }
435
436 static constexpr Color DimGrey() {
437 return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
438 }
439
440 static constexpr Color DodgerBlue() {
441 return {30.0f / 255.0f, 144.0f / 255.0f, 255.0f / 255.0f, 1.0f};
442 }
443
444 static constexpr Color Firebrick() {
445 return {178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f};
446 }
447
448 static constexpr Color FloralWhite() {
449 return {255.0f / 255.0f, 250.0f / 255.0f, 240.0f / 255.0f, 1.0f};
450 }
451
452 static constexpr Color ForestGreen() {
453 return {34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f};
454 }
455
456 static constexpr Color Fuchsia() {
457 return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
458 }
459
460 static constexpr Color Gainsboro() {
461 return {220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f, 1.0f};
462 }
463
464 static constexpr Color Ghostwhite() {
465 return {248.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
466 }
467
468 static constexpr Color Gold() {
469 return {255.0f / 255.0f, 215.0f / 255.0f, 0.0f / 255.0f, 1.0f};
470 }
471
472 static constexpr Color Goldenrod() {
473 return {218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f};
474 }
475
476 static constexpr Color Gray() {
477 return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
478 }
479
480 static constexpr Color GreenYellow() {
481 return {173.0f / 255.0f, 255.0f / 255.0f, 47.0f / 255.0f, 1.0f};
482 }
483
484 static constexpr Color Grey() {
485 return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
486 }
487
488 static constexpr Color Honeydew() {
489 return {240.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
490 }
491
492 static constexpr Color HotPink() {
493 return {255.0f / 255.0f, 105.0f / 255.0f, 180.0f / 255.0f, 1.0f};
494 }
495
496 static constexpr Color IndianRed() {
497 return {205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f};
498 }
499
500 static constexpr Color Indigo() {
501 return {75.0f / 255.0f, 0.0f / 255.0f, 130.0f / 255.0f, 1.0f};
502 }
503
504 static constexpr Color Ivory() {
505 return {255.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
506 }
507
508 static constexpr Color Khaki() {
509 return {240.0f / 255.0f, 230.0f / 255.0f, 140.0f / 255.0f, 1.0f};
510 }
511
512 static constexpr Color Lavender() {
513 return {230.0f / 255.0f, 230.0f / 255.0f, 250.0f / 255.0f, 1.0f};
514 }
515
516 static constexpr Color LavenderBlush() {
517 return {255.0f / 255.0f, 240.0f / 255.0f, 245.0f / 255.0f, 1.0f};
518 }
519
520 static constexpr Color LawnGreen() {
521 return {124.0f / 255.0f, 252.0f / 255.0f, 0.0f / 255.0f, 1.0f};
522 }
523
524 static constexpr Color LemonChiffon() {
525 return {255.0f / 255.0f, 250.0f / 255.0f, 205.0f / 255.0f, 1.0f};
526 }
527
528 static constexpr Color LightBlue() {
529 return {173.0f / 255.0f, 216.0f / 255.0f, 230.0f / 255.0f, 1.0f};
530 }
531
532 static constexpr Color LightCoral() {
533 return {240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
534 }
535
536 static constexpr Color LightCyan() {
537 return {224.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
538 }
539
540 static constexpr Color LightGoldenrodYellow() {
541 return {50.0f / 255.0f, 250.0f / 255.0f, 210.0f / 255.0f, 1.0f};
542 }
543
544 static constexpr Color LightGray() {
545 return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
546 }
547
548 static constexpr Color LightGreen() {
549 return {144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f};
550 }
551
552 static constexpr Color LightGrey() {
553 return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
554 }
555
556 static constexpr Color LightPink() {
557 return {255.0f / 255.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f};
558 }
559
560 static constexpr Color LightSalmon() {
561 return {255.0f / 255.0f, 160.0f / 255.0f, 122.0f / 255.0f, 1.0f};
562 }
563
564 static constexpr Color LightSeaGreen() {
565 return {32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f};
566 }
567
568 static constexpr Color LightSkyBlue() {
569 return {135.0f / 255.0f, 206.0f / 255.0f, 250.0f / 255.0f, 1.0f};
570 }
571
572 static constexpr Color LightSlateGray() {
573 return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
574 }
575
576 static constexpr Color LightSlateGrey() {
577 return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
578 }
579
580 static constexpr Color LightSteelBlue() {
581 return {176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f};
582 }
583
584 static constexpr Color LightYellow() {
585 return {255.0f / 255.0f, 255.0f / 255.0f, 224.0f / 255.0f, 1.0f};
586 }
587
588 static constexpr Color Lime() {
589 return {0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
590 }
591
592 static constexpr Color LimeGreen() {
593 return {50.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
594 }
595
596 static constexpr Color Linen() {
597 return {250.0f / 255.0f, 240.0f / 255.0f, 230.0f / 255.0f, 1.0f};
598 }
599
600 static constexpr Color Magenta() {
601 return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
602 }
603
604 static constexpr Color Maroon() {
605 return {128.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
606 }
607
608 static constexpr Color MediumAquamarine() {
609 return {102.0f / 255.0f, 205.0f / 255.0f, 170.0f / 255.0f, 1.0f};
610 }
611
612 static constexpr Color MediumBlue() {
613 return {0.0f / 255.0f, 0.0f / 255.0f, 205.0f / 255.0f, 1.0f};
614 }
615
616 static constexpr Color MediumOrchid() {
617 return {186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f};
618 }
619
620 static constexpr Color MediumPurple() {
621 return {147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f};
622 }
623
624 static constexpr Color MediumSeagreen() {
625 return {60.0f / 255.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f};
626 }
627
628 static constexpr Color MediumSlateBlue() {
629 return {123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f};
630 }
631
632 static constexpr Color MediumSpringGreen() {
633 return {0.0f / 255.0f, 250.0f / 255.0f, 154.0f / 255.0f, 1.0f};
634 }
635
636 static constexpr Color MediumTurquoise() {
637 return {72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f};
638 }
639
640 static constexpr Color MediumVioletRed() {
641 return {199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f};
642 }
643
644 static constexpr Color MidnightBlue() {
645 return {25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f};
646 }
647
648 static constexpr Color MintCream() {
649 return {245.0f / 255.0f, 255.0f / 255.0f, 250.0f / 255.0f, 1.0f};
650 }
651
652 static constexpr Color MistyRose() {
653 return {255.0f / 255.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f};
654 }
655
656 static constexpr Color Moccasin() {
657 return {255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f};
658 }
659
660 static constexpr Color NavajoWhite() {
661 return {255.0f / 255.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f};
662 }
663
664 static constexpr Color Navy() {
665 return {0.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
666 }
667
668 static constexpr Color OldLace() {
669 return {253.0f / 255.0f, 245.0f / 255.0f, 230.0f / 255.0f, 1.0f};
670 }
671
672 static constexpr Color Olive() {
673 return {128.0f / 255.0f, 128.0f / 255.0f, 0.0f / 255.0f, 1.0f};
674 }
675
676 static constexpr Color OliveDrab() {
677 return {107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f};
678 }
679
680 static constexpr Color Orange() {
681 return {255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f};
682 }
683
684 static constexpr Color OrangeRed() {
685 return {255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f};
686 }
687
688 static constexpr Color Orchid() {
689 return {218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f};
690 }
691
692 static constexpr Color PaleGoldenrod() {
693 return {238.0f / 255.0f, 232.0f / 255.0f, 170.0f / 255.0f, 1.0f};
694 }
695
696 static constexpr Color PaleGreen() {
697 return {152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f};
698 }
699
700 static constexpr Color PaleTurquoise() {
701 return {175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f};
702 }
703
704 static constexpr Color PaleVioletRed() {
705 return {219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f};
706 }
707
708 static constexpr Color PapayaWhip() {
709 return {255.0f / 255.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f};
710 }
711
712 static constexpr Color Peachpuff() {
713 return {255.0f / 255.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f};
714 }
715
716 static constexpr Color Peru() {
717 return {205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f};
718 }
719
720 static constexpr Color Pink() {
721 return {255.0f / 255.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f};
722 }
723
724 static constexpr Color Plum() {
725 return {221.0f / 255.0f, 160.0f / 255.0f, 221.0f / 255.0f, 1.0f};
726 }
727
728 static constexpr Color PowderBlue() {
729 return {176.0f / 255.0f, 224.0f / 255.0f, 230.0f / 255.0f, 1.0f};
730 }
731
732 static constexpr Color Purple() {
733 return {128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
734 }
735
736 static constexpr Color RosyBrown() {
737 return {188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f};
738 }
739
740 static constexpr Color RoyalBlue() {
741 return {65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f};
742 }
743
744 static constexpr Color SaddleBrown() {
745 return {139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f};
746 }
747
748 static constexpr Color Salmon() {
749 return {250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f};
750 }
751
752 static constexpr Color SandyBrown() {
753 return {244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f};
754 }
755
756 static constexpr Color Seagreen() {
757 return {46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f};
758 }
759
760 static constexpr Color Seashell() {
761 return {255.0f / 255.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f};
762 }
763
764 static constexpr Color Sienna() {
765 return {160.0f / 255.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f};
766 }
767
768 static constexpr Color Silver() {
769 return {192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f};
770 }
771
772 static constexpr Color SkyBlue() {
773 return {135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f};
774 }
775
776 static constexpr Color SlateBlue() {
777 return {106.0f / 255.0f, 90.0f / 255.0f, 205.0f / 255.0f, 1.0f};
778 }
779
780 static constexpr Color SlateGray() {
781 return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
782 }
783
784 static constexpr Color SlateGrey() {
785 return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
786 }
787
788 static constexpr Color Snow() {
789 return {255.0f / 255.0f, 250.0f / 255.0f, 250.0f / 255.0f, 1.0f};
790 }
791
792 static constexpr Color SpringGreen() {
793 return {0.0f / 255.0f, 255.0f / 255.0f, 127.0f / 255.0f, 1.0f};
794 }
795
796 static constexpr Color SteelBlue() {
797 return {70.0f / 255.0f, 130.0f / 255.0f, 180.0f / 255.0f, 1.0f};
798 }
799
800 static constexpr Color Tan() {
801 return {210.0f / 255.0f, 180.0f / 255.0f, 140.0f / 255.0f, 1.0f};
802 }
803
804 static constexpr Color Teal() {
805 return {0.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
806 }
807
808 static constexpr Color Thistle() {
809 return {216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f};
810 }
811
812 static constexpr Color Tomato() {
813 return {255.0f / 255.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f};
814 }
815
816 static constexpr Color Turquoise() {
817 return {64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f};
818 }
819
820 static constexpr Color Violet() {
821 return {238.0f / 255.0f, 130.0f / 255.0f, 238.0f / 255.0f, 1.0f};
822 }
823
824 static constexpr Color Wheat() {
825 return {245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f};
826 }
827
828 static constexpr Color Whitesmoke() {
829 return {245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f};
830 }
831
832 static constexpr Color Yellow() {
833 return {255.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
834 }
835
836 static constexpr Color YellowGreen() {
837 return {154.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
838 }
839
840 static Color Random() {
841 return {
842 static_cast<Scalar>((std::rand() % 255) / 255.0f), //
843 static_cast<Scalar>((std::rand() % 255) / 255.0f), //
844 static_cast<Scalar>((std::rand() % 255) / 255.0f), //
845 1.0f //
846 };
847 }
848
849 /// @brief Blends an unpremultiplied destination color into a given
850 /// unpremultiplied source color to form a new unpremultiplied color.
851 ///
852 /// If either the source or destination are premultiplied, the result
853 /// will be incorrect.
854 Color Blend(Color source, BlendMode blend_mode) const;
855
856 /// @brief A color filter that transforms colors through a 4x5 color matrix.
857 ///
858 /// This filter can be used to change the saturation of pixels, convert
859 /// from YUV to RGB, etc.
860 ///
861 /// Each channel of the output color is clamped to the 0 to 1 range.
862 ///
863 /// @see `ColorMatrix`
864 Color ApplyColorMatrix(const ColorMatrix& color_matrix) const;
865
866 /// @brief Convert the color from linear space to sRGB space.
867 ///
868 /// The color is assumed to be unpremultiplied. If the color is
869 /// premultipled, the conversion output will be incorrect.
870 Color LinearToSRGB() const;
871
872 /// @brief Convert the color from sRGB space to linear space.
873 ///
874 /// The color is assumed to be unpremultiplied. If the color is
875 /// premultipled, the conversion output will be incorrect.
876 Color SRGBToLinear() const;
877
878 constexpr bool IsTransparent() const { return alpha == 0.0f; }
879
880 constexpr bool IsOpaque() const { return alpha == 1.0f; }
881 };
882
883 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
884 constexpr inline Color operator+(T value, const Color& c) {
885 return c + static_cast<Scalar>(value);
886 }
887
888 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
889 constexpr inline Color operator-(T value, const Color& c) {
890 auto v = static_cast<Scalar>(value);
891 return {v - c.red, v - c.green, v - c.blue, v - c.alpha};
892 }
893
894 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
895 constexpr inline Color operator*(T value, const Color& c) {
896 return c * static_cast<Scalar>(value);
897 }
898
899 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
900 constexpr inline Color operator/(T value, const Color& c) {
901 auto v = static_cast<Scalar>(value);
902 return {v / c.red, v / c.green, v / c.blue, v / c.alpha};
903 }
904
905 std::string ColorToString(const Color& color);
906
907 /**
908 * Represents a color by its constituent hue, saturation, brightness and alpha
909 */
910 struct ColorHSB {
911 /**
912 * The hue of the color (0 to 1)
913 */
914 Scalar hue;
915
916 /**
917 * The saturation of the color (0 to 1)
918 */
919 Scalar saturation;
920
921 /**
922 * The brightness of the color (0 to 1)
923 */
924 Scalar brightness;
925
926 /**
927 * The alpha of the color (0 to 1)
928 */
929 Scalar alpha;
930
931 constexpr ColorHSB(Scalar h, Scalar s, Scalar b, Scalar a)
932 : hue(h), saturation(s), brightness(b), alpha(a) {}
933
934 static ColorHSB FromRGB(Color rgb);
935
936 Color ToRGBA() const;
937 };
938
939 static_assert(sizeof(Color) == 4 * sizeof(Scalar));
940
941 } // namespace impeller
942
943 namespace std {
944
945 inline std::ostream& operator<<(std::ostream& out, const impeller::Color& c) {
946 out << "(" << c.red << ", " << c.green << ", " << c.blue << ", " << c.alpha
947 << ")";
948 return out;
949 }
950
951 } // namespace std
impeller::Color::DarkMagenta
static constexpr Color DarkMagenta()
Definition: color.h:376
impeller::Color::operator/
constexpr Color operator/(T value) const
Definition: color.h:207
impeller::BlendMode
BlendMode
Definition: color.h:57
impeller::Color::Blue
static constexpr Color Blue()
Definition: color.h:266
impeller::Color::Navy
static constexpr Color Navy()
Definition: color.h:664
impeller::Color::SaddleBrown
static constexpr Color SaddleBrown()
Definition: color.h:744
impeller::Color::DeepPink
static constexpr Color DeepPink()
Definition: color.h:424
impeller::Color::operator*
constexpr Color operator*(T value) const
Definition: color.h:197
impeller::Color::DimGray
static constexpr Color DimGray()
Definition: color.h:432
impeller::BlendModeToString
const char * BlendModeToString(BlendMode blend_mode)
Definition: color.cc:47
impeller::Color::Beige
static constexpr Color Beige()
Definition: color.h:292
impeller::Color::Cyan
static constexpr Color Cyan()
Definition: color.h:344
impeller::Color::MediumOrchid
static constexpr Color MediumOrchid()
Definition: color.h:616
impeller::ColorToString
std::string ColorToString(const Color &color)
Definition: color.cc:398
impeller::Color::DarkSalmon
static constexpr Color DarkSalmon()
Definition: color.h:396
impeller::Color::PaleTurquoise
static constexpr Color PaleTurquoise()
Definition: color.h:700
impeller::Color::SandyBrown
static constexpr Color SandyBrown()
Definition: color.h:752
impeller::Color::YellowGreen
static constexpr Color YellowGreen()
Definition: color.h:836
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::Color::DarkGray
static constexpr Color DarkGray()
Definition: color.h:360
impeller::Color::Seashell
static constexpr Color Seashell()
Definition: color.h:760
impeller::Color::DeepSkyBlue
static constexpr Color DeepSkyBlue()
Definition: color.h:428
impeller::Color::Red
static constexpr Color Red()
Definition: color.h:262
impeller::BlendMode::kMultiply
@ kMultiply
impeller::Color::ForestGreen
static constexpr Color ForestGreen()
Definition: color.h:452
impeller::Color::Color
constexpr Color()
Definition: color.h:143
impeller::Color::BlanchedAlmond
static constexpr Color BlanchedAlmond()
Definition: color.h:300
impeller::Color::Khaki
static constexpr Color Khaki()
Definition: color.h:508
impeller::Color::Lavender
static constexpr Color Lavender()
Definition: color.h:512
impeller::ColorHSB::brightness
Scalar brightness
Definition: color.h:924
impeller::Color::Silver
static constexpr Color Silver()
Definition: color.h:768
impeller::Color::operator+
constexpr Color operator+(T value) const
Definition: color.h:177
impeller::Color::MakeRGBA8
static constexpr Color MakeRGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Definition: color.h:152
impeller::Color
Definition: color.h:122
impeller::Color::MediumAquamarine
static constexpr Color MediumAquamarine()
Definition: color.h:608
impeller::Color::Indigo
static constexpr Color Indigo()
Definition: color.h:500
impeller::Color::Unpremultiply
constexpr Color Unpremultiply() const
Definition: color.h:216
impeller::Color::Tan
static constexpr Color Tan()
Definition: color.h:800
impeller::Color::IsTransparent
constexpr bool IsTransparent() const
Definition: color.h:878
impeller::Color::SlateBlue
static constexpr Color SlateBlue()
Definition: color.h:776
impeller::Color::LightSkyBlue
static constexpr Color LightSkyBlue()
Definition: color.h:568
impeller::Color::Teal
static constexpr Color Teal()
Definition: color.h:804
impeller::Color::LightSlateGrey
static constexpr Color LightSlateGrey()
Definition: color.h:576
impeller::Color::Gainsboro
static constexpr Color Gainsboro()
Definition: color.h:460
impeller::Vector4
Definition: vector.h:229
impeller::Color::MediumPurple
static constexpr Color MediumPurple()
Definition: color.h:620
impeller::Color::Chocolate
static constexpr Color Chocolate()
Definition: color.h:324
impeller::Color::Purple
static constexpr Color Purple()
Definition: color.h:732
impeller::Color::PaleGreen
static constexpr Color PaleGreen()
Definition: color.h:696
impeller::BlendMode::kSourceIn
@ kSourceIn
impeller::Color::Turquoise
static constexpr Color Turquoise()
Definition: color.h:816
impeller::Color::alpha
Scalar alpha
Definition: color.h:141
impeller::BlendMode::kSaturation
@ kSaturation
impeller::Color::DarkSlateGrey
static constexpr Color DarkSlateGrey()
Definition: color.h:412
impeller::Color::MintCream
static constexpr Color MintCream()
Definition: color.h:648
std::operator<<
std::ostream & operator<<(std::ostream &out, const impeller::Color &c)
Definition: color.h:945
impeller::Color::SlateGrey
static constexpr Color SlateGrey()
Definition: color.h:784
impeller::Color::CadetBlue
static constexpr Color CadetBlue()
Definition: color.h:316
impeller::Color::operator-
constexpr Color operator-(T value) const
Definition: color.h:187
impeller::Color::CornflowerBlue
static constexpr Color CornflowerBlue()
Definition: color.h:332
impeller::Color::LightGrey
static constexpr Color LightGrey()
Definition: color.h:552
impeller::Color::DodgerBlue
static constexpr Color DodgerBlue()
Definition: color.h:440
impeller::BlendMode::kHue
@ kHue
impeller::Color::LightCyan
static constexpr Color LightCyan()
Definition: color.h:536
impeller::Color::Yellow
static constexpr Color Yellow()
Definition: color.h:832
impeller::Color::Fuchsia
static constexpr Color Fuchsia()
Definition: color.h:456
impeller::operator*
constexpr Color operator*(T value, const Color &c)
Definition: color.h:895
impeller::BlendMode::kDestinationIn
@ kDestinationIn
impeller::BlendMode::kDarken
@ kDarken
impeller::Color::LightGray
static constexpr Color LightGray()
Definition: color.h:544
impeller::Color::Wheat
static constexpr Color Wheat()
Definition: color.h:824
impeller::BlendMode::kColor
@ kColor
impeller::Color::Clamp01
constexpr Color Clamp01() const
Definition: color.h:236
impeller::Color::green
Scalar green
Definition: color.h:131
impeller::Color::DarkViolet
static constexpr Color DarkViolet()
Definition: color.h:420
impeller::Color::Snow
static constexpr Color Snow()
Definition: color.h:788
impeller::Color::PapayaWhip
static constexpr Color PapayaWhip()
Definition: color.h:708
impeller::Color::Maroon
static constexpr Color Maroon()
Definition: color.h:604
impeller::Color::NavajoWhite
static constexpr Color NavajoWhite()
Definition: color.h:660
impeller::BlendMode::kLuminosity
@ kLuminosity
impeller::Color::DarkGrey
static constexpr Color DarkGrey()
Definition: color.h:368
impeller::BlendMode::kXor
@ kXor
impeller::Color::DarkKhaki
static constexpr Color DarkKhaki()
Definition: color.h:372
impeller::Color::LightPink
static constexpr Color LightPink()
Definition: color.h:556
impeller::Color::Ivory
static constexpr Color Ivory()
Definition: color.h:504
impeller::BlendMode::kOverlay
@ kOverlay
impeller::ColorHSB
Definition: color.h:910
impeller::BlendMode::kColorBurn
@ kColorBurn
impeller::Color::PaleGoldenrod
static constexpr Color PaleGoldenrod()
Definition: color.h:692
impeller::Color::Brown
static constexpr Color Brown()
Definition: color.h:308
impeller::Color::Magenta
static constexpr Color Magenta()
Definition: color.h:600
impeller::Color::MidnightBlue
static constexpr Color MidnightBlue()
Definition: color.h:644
impeller::Color::DarkSlateGray
static constexpr Color DarkSlateGray()
Definition: color.h:408
impeller::Color::Goldenrod
static constexpr Color Goldenrod()
Definition: color.h:472
impeller::Color::operator*
constexpr Color operator*(const Color &c) const
Definition: color.h:192
impeller::Color::PowderBlue
static constexpr Color PowderBlue()
Definition: color.h:728
impeller::BlendMode::kLighten
@ kLighten
impeller::Color::Gray
static constexpr Color Gray()
Definition: color.h:476
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::Color::LemonChiffon
static constexpr Color LemonChiffon()
Definition: color.h:524
impeller::Color::OrangeRed
static constexpr Color OrangeRed()
Definition: color.h:684
impeller::Color::Azure
static constexpr Color Azure()
Definition: color.h:288
impeller::BlendMode::kHardLight
@ kHardLight
impeller::Color::Firebrick
static constexpr Color Firebrick()
Definition: color.h:444
impeller::Color::operator-
constexpr Color operator-(const Color &c) const
Definition: color.h:182
impeller::Color::Gold
static constexpr Color Gold()
Definition: color.h:468
impeller::Color::ToIColor
static constexpr uint32_t ToIColor(Color color)
Convert this color to a 32-bit representation.
Definition: color.h:159
impeller::Color::PaleVioletRed
static constexpr Color PaleVioletRed()
Definition: color.h:704
impeller::BlendMode::kPlus
@ kPlus
impeller::BlendMode::kDestination
@ kDestination
impeller::Color::SRGBToLinear
Color SRGBToLinear() const
Convert the color from sRGB space to linear space.
Definition: color.cc:387
impeller::ColorHSB::alpha
Scalar alpha
Definition: color.h:929
impeller::Color::Honeydew
static constexpr Color Honeydew()
Definition: color.h:488
impeller::Color::Salmon
static constexpr Color Salmon()
Definition: color.h:748
impeller::Color::LightBlue
static constexpr Color LightBlue()
Definition: color.h:528
impeller::YUVColorSpace::kBT601FullRange
@ kBT601FullRange
impeller::Color::OldLace
static constexpr Color OldLace()
Definition: color.h:668
impeller::Color::DarkBlue
static constexpr Color DarkBlue()
Definition: color.h:348
impeller::Color::IndianRed
static constexpr Color IndianRed()
Definition: color.h:496
impeller::Color::WithAlpha
constexpr Color WithAlpha(Scalar new_alpha) const
Definition: color.h:268
impeller::Color::MediumVioletRed
static constexpr Color MediumVioletRed()
Definition: color.h:640
impeller::Color::SkyBlue
static constexpr Color SkyBlue()
Definition: color.h:772
impeller::Color::DarkSlateBlue
static constexpr Color DarkSlateBlue()
Definition: color.h:404
impeller::ColorMatrix::array
Scalar array[20]
Definition: color.h:116
impeller::Color::RoyalBlue
static constexpr Color RoyalBlue()
Definition: color.h:740
impeller::Color::LightSlateGray
static constexpr Color LightSlateGray()
Definition: color.h:572
impeller::Color::operator+
constexpr Color operator+(const Color &c) const
Definition: color.h:172
impeller::Color::ToR8G8B8A8
constexpr std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
Definition: color.h:246
impeller::Color::red
Scalar red
Definition: color.h:126
impeller::Color::MistyRose
static constexpr Color MistyRose()
Definition: color.h:652
impeller::Color::AquaMarine
static constexpr Color AquaMarine()
Definition: color.h:284
impeller::Color::LightCoral
static constexpr Color LightCoral()
Definition: color.h:532
impeller::BlendMode::kDestinationATop
@ kDestinationATop
impeller::Color::Random
static Color Random()
Definition: color.h:840
impeller::Color::LightSteelBlue
static constexpr Color LightSteelBlue()
Definition: color.h:580
impeller::Color::Grey
static constexpr Color Grey()
Definition: color.h:484
impeller::Color::Cornsilk
static constexpr Color Cornsilk()
Definition: color.h:336
impeller::Color::White
static constexpr Color White()
Definition: color.h:254
impeller::Color::Violet
static constexpr Color Violet()
Definition: color.h:820
impeller::Color::Peachpuff
static constexpr Color Peachpuff()
Definition: color.h:712
impeller::Color::Moccasin
static constexpr Color Moccasin()
Definition: color.h:656
impeller::Color::Chartreuse
static constexpr Color Chartreuse()
Definition: color.h:320
impeller::Color::Pink
static constexpr Color Pink()
Definition: color.h:720
impeller::Color::LightYellow
static constexpr Color LightYellow()
Definition: color.h:584
impeller::Color::Peru
static constexpr Color Peru()
Definition: color.h:716
impeller::Color::OliveDrab
static constexpr Color OliveDrab()
Definition: color.h:676
impeller::Color::Green
static constexpr Color Green()
Definition: color.h:264
impeller::Color::LightGreen
static constexpr Color LightGreen()
Definition: color.h:548
impeller::Color::HotPink
static constexpr Color HotPink()
Definition: color.h:492
impeller::Color::DarkOrchid
static constexpr Color DarkOrchid()
Definition: color.h:388
impeller::Color::MediumBlue
static constexpr Color MediumBlue()
Definition: color.h:612
impeller::Color::DarkOliveGreen
static constexpr Color DarkOliveGreen()
Definition: color.h:380
impeller::BlendMode::kDestinationOut
@ kDestinationOut
impeller::Color::Linen
static constexpr Color Linen()
Definition: color.h:596
impeller::ColorHSB::FromRGB
static ColorHSB FromRGB(Color rgb)
Definition: color.cc:52
impeller::YUVColorSpace::kBT601LimitedRange
@ kBT601LimitedRange
impeller::BlendMode::kSoftLight
@ kSoftLight
impeller::Color::Color
constexpr Color(Scalar r, Scalar g, Scalar b, Scalar a)
Definition: color.h:149
impeller::Color::SpringGreen
static constexpr Color SpringGreen()
Definition: color.h:792
impeller::operator-
constexpr Color operator-(T value, const Color &c)
Definition: color.h:889
scalar.h
impeller::Color::AntiqueWhite
static constexpr Color AntiqueWhite()
Definition: color.h:276
impeller::ColorHSB::ToRGBA
Color ToRGBA() const
Definition: color.cc:79
impeller::Color::LightSeaGreen
static constexpr Color LightSeaGreen()
Definition: color.h:564
impeller::BlendMode::kDifference
@ kDifference
impeller::Color::MediumTurquoise
static constexpr Color MediumTurquoise()
Definition: color.h:636
impeller::Color::Ghostwhite
static constexpr Color Ghostwhite()
Definition: color.h:464
impeller::Color::SlateGray
static constexpr Color SlateGray()
Definition: color.h:780
impeller::Color::GreenYellow
static constexpr Color GreenYellow()
Definition: color.h:480
impeller::Color::DarkCyan
static constexpr Color DarkCyan()
Definition: color.h:352
impeller::Color::Orange
static constexpr Color Orange()
Definition: color.h:680
impeller::BlendMode::kExclusion
@ kExclusion
std
Definition: comparable.h:98
impeller::Color::SteelBlue
static constexpr Color SteelBlue()
Definition: color.h:796
impeller::Color::FloralWhite
static constexpr Color FloralWhite()
Definition: color.h:448
impeller::ColorHSB::saturation
Scalar saturation
Definition: color.h:919
type_traits.h
impeller::BlendMode::kDestinationOver
@ kDestinationOver
impeller::Color::RosyBrown
static constexpr Color RosyBrown()
Definition: color.h:736
impeller::Color::DarkTurquoise
static constexpr Color DarkTurquoise()
Definition: color.h:416
impeller::ColorHSB::ColorHSB
constexpr ColorHSB(Scalar h, Scalar s, Scalar b, Scalar a)
Definition: color.h:931
impeller::Color::LightGoldenrodYellow
static constexpr Color LightGoldenrodYellow()
Definition: color.h:540
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:260
impeller::Color::Black
static constexpr Color Black()
Definition: color.h:256
impeller::Color::MediumSpringGreen
static constexpr Color MediumSpringGreen()
Definition: color.h:632
impeller::Color::Bisque
static constexpr Color Bisque()
Definition: color.h:296
impeller::BlendMode::kClear
@ kClear
impeller::Color::Sienna
static constexpr Color Sienna()
Definition: color.h:764
impeller::Color::Thistle
static constexpr Color Thistle()
Definition: color.h:808
impeller::Color::Olive
static constexpr Color Olive()
Definition: color.h:672
impeller::ScalarNearlyEqual
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
Definition: scalar.h:27
impeller::BlendMode::kLast
@ kLast
impeller::YUVColorSpace
YUVColorSpace
Definition: color.h:53
impeller::Color::Tomato
static constexpr Color Tomato()
Definition: color.h:812
impeller::operator/
constexpr Color operator/(T value, const Color &c)
Definition: color.h:900
impeller::Color::BlueViolet
static constexpr Color BlueViolet()
Definition: color.h:304
impeller::Color::LimeGreen
static constexpr Color LimeGreen()
Definition: color.h:592
impeller::Color::Whitesmoke
static constexpr Color Whitesmoke()
Definition: color.h:828
impeller::Color::WhiteTransparent
static constexpr Color WhiteTransparent()
Definition: color.h:258
impeller::Color::LawnGreen
static constexpr Color LawnGreen()
Definition: color.h:520
impeller::Color::operator==
constexpr bool operator==(const Color &c) const
Definition: color.h:167
impeller::Color::AliceBlue
static constexpr Color AliceBlue()
Definition: color.h:272
impeller::Color::DarkGreen
static constexpr Color DarkGreen()
Definition: color.h:364
impeller::BlendMode::kColorDodge
@ kColorDodge
impeller::Color::DarkOrange
static constexpr Color DarkOrange()
Definition: color.h:384
impeller::BlendMode::kSourceATop
@ kSourceATop
impeller::BlendMode::kModulate
@ kModulate
impeller::Color::DarkGoldenrod
static constexpr Color DarkGoldenrod()
Definition: color.h:356
impeller::Color::DarkRed
static constexpr Color DarkRed()
Definition: color.h:392
impeller::Color::Seagreen
static constexpr Color Seagreen()
Definition: color.h:756
impeller::Color::Lerp
constexpr static Color Lerp(Color a, Color b, Scalar t)
Return a color that is linearly interpolated between colors a and b, according to the value of t.
Definition: color.h:232
impeller::Color::IsOpaque
constexpr bool IsOpaque() const
Definition: color.h:880
impeller::Color::blue
Scalar blue
Definition: color.h:136
impeller::Color::LightSalmon
static constexpr Color LightSalmon()
Definition: color.h:560
impeller::Color::Coral
static constexpr Color Coral()
Definition: color.h:328
impeller::ColorMatrix
Definition: color.h:115
impeller::Color::ApplyColorMatrix
Color ApplyColorMatrix(const ColorMatrix &color_matrix) const
A color filter that transforms colors through a 4x5 color matrix.
Definition: color.cc:366
impeller::Color::LinearToSRGB
Color LinearToSRGB() const
Convert the color from linear space to sRGB space.
Definition: color.cc:376
impeller::Color::LavenderBlush
static constexpr Color LavenderBlush()
Definition: color.h:516
impeller::Color::operator/
constexpr Color operator/(const Color &c) const
Definition: color.h:202
impeller::Color::DarkSeagreen
static constexpr Color DarkSeagreen()
Definition: color.h:400
impeller::Color::Plum
static constexpr Color Plum()
Definition: color.h:724
impeller::BlendMode::kScreen
@ kScreen
impeller
Definition: aiks_context.cc:10
impeller::Color::MediumSlateBlue
static constexpr Color MediumSlateBlue()
Definition: color.h:628
impeller::Color::DimGrey
static constexpr Color DimGrey()
Definition: color.h:436
impeller::Color::BurlyWood
static constexpr Color BurlyWood()
Definition: color.h:312
impeller::BlendMode::kSourceOut
@ kSourceOut
impeller::Color::Orchid
static constexpr Color Orchid()
Definition: color.h:688
impeller::Color::Premultiply
constexpr Color Premultiply() const
Definition: color.h:212
impeller::BlendMode::kSource
@ kSource
impeller::Color::Aqua
static constexpr Color Aqua()
Definition: color.h:280
impeller::Color::Lime
static constexpr Color Lime()
Definition: color.h:588
impeller::Color::MediumSeagreen
static constexpr Color MediumSeagreen()
Definition: color.h:624
impeller::Color::Crimson
static constexpr Color Crimson()
Definition: color.h:340
impeller::ColorHSB::hue
Scalar hue
Definition: color.h:914
impeller::operator+
constexpr Color operator+(T value, const Color &c)
Definition: color.h:884
impeller::Color::Blend
Color Blend(Color source, BlendMode blend_mode) const
Blends an unpremultiplied destination color into a given unpremultiplied source color to form a new u...
Definition: color.cc:222