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