| 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(Src) \
22 V(Dst) \
23 V(SrcOver) \
24 V(DstOver) \
25 V(SrcIn) \
26 V(DstIn) \
27 V(SrcOut) \
28 V(DstOut) \
29 V(SrcATop) \
30 V(DstATop) \
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 Vector4;
53
54 enum class YUVColorSpace { kBT601LimitedRange, kBT601FullRange };
55
56 /// All blend modes assume that both the source (fragment output) and
57 /// destination (first color attachment) have colors with premultiplied alpha.
58 enum class BlendMode : uint8_t {
59 // The following blend modes are able to be used as pipeline blend modes or
60 // via `BlendFilterContents`.
61 kClear = 0,
62 kSrc,
63 kDst,
64 kSrcOver,
65 kDstOver,
66 kSrcIn,
67 kDstIn,
68 kSrcOut,
69 kDstOut,
70 kSrcATop,
71 kDstATop,
72 kXor,
73 kPlus,
74 kModulate,
75
76 // The following blend modes use equations that are not available for
77 // pipelines on most graphics devices without extensions, and so they are
78 // only able to be used via `BlendFilterContents`.
79 kScreen,
80 kOverlay,
81 kDarken,
82 kLighten,
83 kColorDodge,
84 kColorBurn,
85 kHardLight,
86 kSoftLight,
87 kDifference,
88 kExclusion,
89 kMultiply,
90 kHue,
91 kSaturation,
92 kColor,
93 kLuminosity,
94
95 kLastMode = kLuminosity,
96 kDefaultMode = kSrcOver,
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 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 inline 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 inline 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 /**
255 * @brief Convert to ARGB 32 bit color.
256 *
257 * @return constexpr uint32_t
258 */
259 inline uint32_t ToARGB() const {
260 std::array<uint8_t, 4> result = ToR8G8B8A8();
261 return result[3] << 24 | result[0] << 16 | result[1] << 8 | result[2];
262 }
263
264 static constexpr Color White() { return {1.0f, 1.0f, 1.0f, 1.0f}; }
265
266 static constexpr Color Black() { return {0.0f, 0.0f, 0.0f, 1.0f}; }
267
268 static constexpr Color WhiteTransparent() { return {1.0f, 1.0f, 1.0f, 0.0f}; }
269
270 static constexpr Color BlackTransparent() { return {0.0f, 0.0f, 0.0f, 0.0f}; }
271
272 static constexpr Color Red() { return {1.0f, 0.0f, 0.0f, 1.0f}; }
273
274 static constexpr Color Green() { return {0.0f, 1.0f, 0.0f, 1.0f}; }
275
276 static constexpr Color Blue() { return {0.0f, 0.0f, 1.0f, 1.0f}; }
277
278 constexpr Color WithAlpha(Scalar new_alpha) const {
279 return {red, green, blue, new_alpha};
280 }
281
282 static constexpr Color AliceBlue() {
283 return {240.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
284 }
285
286 static constexpr Color AntiqueWhite() {
287 return {250.0f / 255.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f};
288 }
289
290 static constexpr Color Aqua() {
291 return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
292 }
293
294 static constexpr Color AquaMarine() {
295 return {127.0f / 255.0f, 255.0f / 255.0f, 212.0f / 255.0f, 1.0f};
296 }
297
298 static constexpr Color Azure() {
299 return {240.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
300 }
301
302 static constexpr Color Beige() {
303 return {245.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f, 1.0f};
304 }
305
306 static constexpr Color Bisque() {
307 return {255.0f / 255.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f};
308 }
309
310 static constexpr Color BlanchedAlmond() {
311 return {255.0f / 255.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f};
312 }
313
314 static constexpr Color BlueViolet() {
315 return {138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f};
316 }
317
318 static constexpr Color Brown() {
319 return {165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f};
320 }
321
322 static constexpr Color BurlyWood() {
323 return {222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f};
324 }
325
326 static constexpr Color CadetBlue() {
327 return {95.0f / 255.0f, 158.0f / 255.0f, 160.0f / 255.0f, 1.0f};
328 }
329
330 static constexpr Color Chartreuse() {
331 return {127.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
332 }
333
334 static constexpr Color Chocolate() {
335 return {210.0f / 255.0f, 105.0f / 255.0f, 30.0f / 255.0f, 1.0f};
336 }
337
338 static constexpr Color Coral() {
339 return {255.0f / 255.0f, 127.0f / 255.0f, 80.0f / 255.0f, 1.0f};
340 }
341
342 static constexpr Color CornflowerBlue() {
343 return {100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f};
344 }
345
346 static constexpr Color Cornsilk() {
347 return {255.0f / 255.0f, 248.0f / 255.0f, 220.0f / 255.0f, 1.0f};
348 }
349
350 static constexpr Color Crimson() {
351 return {220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f};
352 }
353
354 static constexpr Color Cyan() {
355 return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
356 }
357
358 static constexpr Color DarkBlue() {
359 return {0.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
360 }
361
362 static constexpr Color DarkCyan() {
363 return {0.0f / 255.0f, 139.0f / 255.0f, 139.0f / 255.0f, 1.0f};
364 }
365
366 static constexpr Color DarkGoldenrod() {
367 return {184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f};
368 }
369
370 static constexpr Color DarkGray() {
371 return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
372 }
373
374 static constexpr Color DarkGreen() {
375 return {0.0f / 255.0f, 100.0f / 255.0f, 0.0f / 255.0f, 1.0f};
376 }
377
378 static constexpr Color DarkGrey() {
379 return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
380 }
381
382 static constexpr Color DarkKhaki() {
383 return {189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f};
384 }
385
386 static constexpr Color DarkMagenta() {
387 return {139.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
388 }
389
390 static constexpr Color DarkOliveGreen() {
391 return {85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f};
392 }
393
394 static constexpr Color DarkOrange() {
395 return {255.0f / 255.0f, 140.0f / 255.0f, 0.0f / 255.0f, 1.0f};
396 }
397
398 static constexpr Color DarkOrchid() {
399 return {153.0f / 255.0f, 50.0f / 255.0f, 204.0f / 255.0f, 1.0f};
400 }
401
402 static constexpr Color DarkRed() {
403 return {139.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
404 }
405
406 static constexpr Color DarkSalmon() {
407 return {233.0f / 255.0f, 150.0f / 255.0f, 122.0f / 255.0f, 1.0f};
408 }
409
410 static constexpr Color DarkSeagreen() {
411 return {143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f};
412 }
413
414 static constexpr Color DarkSlateBlue() {
415 return {72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f};
416 }
417
418 static constexpr Color DarkSlateGray() {
419 return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
420 }
421
422 static constexpr Color DarkSlateGrey() {
423 return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
424 }
425
426 static constexpr Color DarkTurquoise() {
427 return {0.0f / 255.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f};
428 }
429
430 static constexpr Color DarkViolet() {
431 return {148.0f / 255.0f, 0.0f / 255.0f, 211.0f / 255.0f, 1.0f};
432 }
433
434 static constexpr Color DeepPink() {
435 return {255.0f / 255.0f, 20.0f / 255.0f, 147.0f / 255.0f, 1.0f};
436 }
437
438 static constexpr Color DeepSkyBlue() {
439 return {0.0f / 255.0f, 191.0f / 255.0f, 255.0f / 255.0f, 1.0f};
440 }
441
442 static constexpr Color DimGray() {
443 return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
444 }
445
446 static constexpr Color DimGrey() {
447 return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
448 }
449
450 static constexpr Color DodgerBlue() {
451 return {30.0f / 255.0f, 144.0f / 255.0f, 255.0f / 255.0f, 1.0f};
452 }
453
454 static constexpr Color Firebrick() {
455 return {178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f};
456 }
457
458 static constexpr Color FloralWhite() {
459 return {255.0f / 255.0f, 250.0f / 255.0f, 240.0f / 255.0f, 1.0f};
460 }
461
462 static constexpr Color ForestGreen() {
463 return {34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f};
464 }
465
466 static constexpr Color Fuchsia() {
467 return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
468 }
469
470 static constexpr Color Gainsboro() {
471 return {220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f, 1.0f};
472 }
473
474 static constexpr Color Ghostwhite() {
475 return {248.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
476 }
477
478 static constexpr Color Gold() {
479 return {255.0f / 255.0f, 215.0f / 255.0f, 0.0f / 255.0f, 1.0f};
480 }
481
482 static constexpr Color Goldenrod() {
483 return {218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f};
484 }
485
486 static constexpr Color Gray() {
487 return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
488 }
489
490 static constexpr Color GreenYellow() {
491 return {173.0f / 255.0f, 255.0f / 255.0f, 47.0f / 255.0f, 1.0f};
492 }
493
494 static constexpr Color Grey() {
495 return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
496 }
497
498 static constexpr Color Honeydew() {
499 return {240.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
500 }
501
502 static constexpr Color HotPink() {
503 return {255.0f / 255.0f, 105.0f / 255.0f, 180.0f / 255.0f, 1.0f};
504 }
505
506 static constexpr Color IndianRed() {
507 return {205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f};
508 }
509
510 static constexpr Color Indigo() {
511 return {75.0f / 255.0f, 0.0f / 255.0f, 130.0f / 255.0f, 1.0f};
512 }
513
514 static constexpr Color Ivory() {
515 return {255.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
516 }
517
518 static constexpr Color Khaki() {
519 return {240.0f / 255.0f, 230.0f / 255.0f, 140.0f / 255.0f, 1.0f};
520 }
521
522 static constexpr Color Lavender() {
523 return {230.0f / 255.0f, 230.0f / 255.0f, 250.0f / 255.0f, 1.0f};
524 }
525
526 static constexpr Color LavenderBlush() {
527 return {255.0f / 255.0f, 240.0f / 255.0f, 245.0f / 255.0f, 1.0f};
528 }
529
530 static constexpr Color LawnGreen() {
531 return {124.0f / 255.0f, 252.0f / 255.0f, 0.0f / 255.0f, 1.0f};
532 }
533
534 static constexpr Color LemonChiffon() {
535 return {255.0f / 255.0f, 250.0f / 255.0f, 205.0f / 255.0f, 1.0f};
536 }
537
538 static constexpr Color LightBlue() {
539 return {173.0f / 255.0f, 216.0f / 255.0f, 230.0f / 255.0f, 1.0f};
540 }
541
542 static constexpr Color LightCoral() {
543 return {240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
544 }
545
546 static constexpr Color LightCyan() {
547 return {224.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
548 }
549
550 static constexpr Color LightGoldenrodYellow() {
551 return {50.0f / 255.0f, 250.0f / 255.0f, 210.0f / 255.0f, 1.0f};
552 }
553
554 static constexpr Color LightGray() {
555 return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
556 }
557
558 static constexpr Color LightGreen() {
559 return {144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f};
560 }
561
562 static constexpr Color LightGrey() {
563 return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
564 }
565
566 static constexpr Color LightPink() {
567 return {255.0f / 255.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f};
568 }
569
570 static constexpr Color LightSalmon() {
571 return {255.0f / 255.0f, 160.0f / 255.0f, 122.0f / 255.0f, 1.0f};
572 }
573
574 static constexpr Color LightSeaGreen() {
575 return {32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f};
576 }
577
578 static constexpr Color LightSkyBlue() {
579 return {135.0f / 255.0f, 206.0f / 255.0f, 250.0f / 255.0f, 1.0f};
580 }
581
582 static constexpr Color LightSlateGray() {
583 return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
584 }
585
586 static constexpr Color LightSlateGrey() {
587 return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
588 }
589
590 static constexpr Color LightSteelBlue() {
591 return {176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f};
592 }
593
594 static constexpr Color LightYellow() {
595 return {255.0f / 255.0f, 255.0f / 255.0f, 224.0f / 255.0f, 1.0f};
596 }
597
598 static constexpr Color Lime() {
599 return {0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
600 }
601
602 static constexpr Color LimeGreen() {
603 return {50.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
604 }
605
606 static constexpr Color Linen() {
607 return {250.0f / 255.0f, 240.0f / 255.0f, 230.0f / 255.0f, 1.0f};
608 }
609
610 static constexpr Color Magenta() {
611 return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
612 }
613
614 static constexpr Color Maroon() {
615 return {128.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
616 }
617
618 static constexpr Color MediumAquamarine() {
619 return {102.0f / 255.0f, 205.0f / 255.0f, 170.0f / 255.0f, 1.0f};
620 }
621
622 static constexpr Color MediumBlue() {
623 return {0.0f / 255.0f, 0.0f / 255.0f, 205.0f / 255.0f, 1.0f};
624 }
625
626 static constexpr Color MediumOrchid() {
627 return {186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f};
628 }
629
630 static constexpr Color MediumPurple() {
631 return {147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f};
632 }
633
634 static constexpr Color MediumSeagreen() {
635 return {60.0f / 255.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f};
636 }
637
638 static constexpr Color MediumSlateBlue() {
639 return {123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f};
640 }
641
642 static constexpr Color MediumSpringGreen() {
643 return {0.0f / 255.0f, 250.0f / 255.0f, 154.0f / 255.0f, 1.0f};
644 }
645
646 static constexpr Color MediumTurquoise() {
647 return {72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f};
648 }
649
650 static constexpr Color MediumVioletRed() {
651 return {199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f};
652 }
653
654 static constexpr Color MidnightBlue() {
655 return {25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f};
656 }
657
658 static constexpr Color MintCream() {
659 return {245.0f / 255.0f, 255.0f / 255.0f, 250.0f / 255.0f, 1.0f};
660 }
661
662 static constexpr Color MistyRose() {
663 return {255.0f / 255.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f};
664 }
665
666 static constexpr Color Moccasin() {
667 return {255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f};
668 }
669
670 static constexpr Color NavajoWhite() {
671 return {255.0f / 255.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f};
672 }
673
674 static constexpr Color Navy() {
675 return {0.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
676 }
677
678 static constexpr Color OldLace() {
679 return {253.0f / 255.0f, 245.0f / 255.0f, 230.0f / 255.0f, 1.0f};
680 }
681
682 static constexpr Color Olive() {
683 return {128.0f / 255.0f, 128.0f / 255.0f, 0.0f / 255.0f, 1.0f};
684 }
685
686 static constexpr Color OliveDrab() {
687 return {107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f};
688 }
689
690 static constexpr Color Orange() {
691 return {255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f};
692 }
693
694 static constexpr Color OrangeRed() {
695 return {255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f};
696 }
697
698 static constexpr Color Orchid() {
699 return {218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f};
700 }
701
702 static constexpr Color PaleGoldenrod() {
703 return {238.0f / 255.0f, 232.0f / 255.0f, 170.0f / 255.0f, 1.0f};
704 }
705
706 static constexpr Color PaleGreen() {
707 return {152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f};
708 }
709
710 static constexpr Color PaleTurquoise() {
711 return {175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f};
712 }
713
714 static constexpr Color PaleVioletRed() {
715 return {219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f};
716 }
717
718 static constexpr Color PapayaWhip() {
719 return {255.0f / 255.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f};
720 }
721
722 static constexpr Color Peachpuff() {
723 return {255.0f / 255.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f};
724 }
725
726 static constexpr Color Peru() {
727 return {205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f};
728 }
729
730 static constexpr Color Pink() {
731 return {255.0f / 255.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f};
732 }
733
734 static constexpr Color Plum() {
735 return {221.0f / 255.0f, 160.0f / 255.0f, 221.0f / 255.0f, 1.0f};
736 }
737
738 static constexpr Color PowderBlue() {
739 return {176.0f / 255.0f, 224.0f / 255.0f, 230.0f / 255.0f, 1.0f};
740 }
741
742 static constexpr Color Purple() {
743 return {128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
744 }
745
746 static constexpr Color RosyBrown() {
747 return {188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f};
748 }
749
750 static constexpr Color RoyalBlue() {
751 return {65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f};
752 }
753
754 static constexpr Color SaddleBrown() {
755 return {139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f};
756 }
757
758 static constexpr Color Salmon() {
759 return {250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f};
760 }
761
762 static constexpr Color SandyBrown() {
763 return {244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f};
764 }
765
766 static constexpr Color Seagreen() {
767 return {46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f};
768 }
769
770 static constexpr Color Seashell() {
771 return {255.0f / 255.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f};
772 }
773
774 static constexpr Color Sienna() {
775 return {160.0f / 255.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f};
776 }
777
778 static constexpr Color Silver() {
779 return {192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f};
780 }
781
782 static constexpr Color SkyBlue() {
783 return {135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f};
784 }
785
786 static constexpr Color SlateBlue() {
787 return {106.0f / 255.0f, 90.0f / 255.0f, 205.0f / 255.0f, 1.0f};
788 }
789
790 static constexpr Color SlateGray() {
791 return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
792 }
793
794 static constexpr Color SlateGrey() {
795 return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
796 }
797
798 static constexpr Color Snow() {
799 return {255.0f / 255.0f, 250.0f / 255.0f, 250.0f / 255.0f, 1.0f};
800 }
801
802 static constexpr Color SpringGreen() {
803 return {0.0f / 255.0f, 255.0f / 255.0f, 127.0f / 255.0f, 1.0f};
804 }
805
806 static constexpr Color SteelBlue() {
807 return {70.0f / 255.0f, 130.0f / 255.0f, 180.0f / 255.0f, 1.0f};
808 }
809
810 static constexpr Color Tan() {
811 return {210.0f / 255.0f, 180.0f / 255.0f, 140.0f / 255.0f, 1.0f};
812 }
813
814 static constexpr Color Teal() {
815 return {0.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
816 }
817
818 static constexpr Color Thistle() {
819 return {216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f};
820 }
821
822 static constexpr Color Tomato() {
823 return {255.0f / 255.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f};
824 }
825
826 static constexpr Color Turquoise() {
827 return {64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f};
828 }
829
830 static constexpr Color Violet() {
831 return {238.0f / 255.0f, 130.0f / 255.0f, 238.0f / 255.0f, 1.0f};
832 }
833
834 static constexpr Color Wheat() {
835 return {245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f};
836 }
837
838 static constexpr Color Whitesmoke() {
839 return {245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f};
840 }
841
842 static constexpr Color Yellow() {
843 return {255.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
844 }
845
846 static constexpr Color YellowGreen() {
847 return {154.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
848 }
849
850 static Color Random() {
851 return {
852 // This method is not used for cryptographic purposes.
853 // NOLINTBEGIN(clang-analyzer-security.insecureAPI.rand)
854 static_cast<Scalar>((std::rand() % 255) / 255.0f), //
855 static_cast<Scalar>((std::rand() % 255) / 255.0f), //
856 static_cast<Scalar>((std::rand() % 255) / 255.0f), //
857 // NOLINTEND(clang-analyzer-security.insecureAPI.rand)
858 1.0f //
859
860 };
861 }
862
863 /// @brief Blends an unpremultiplied destination color into a given
864 /// unpremultiplied source color to form a new unpremultiplied color.
865 ///
866 /// If either the source or destination are premultiplied, the result
867 /// will be incorrect.
868 Color Blend(Color source, BlendMode blend_mode) const;
869
870 /// @brief A color filter that transforms colors through a 4x5 color matrix.
871 ///
872 /// This filter can be used to change the saturation of pixels, convert
873 /// from YUV to RGB, etc.
874 ///
875 /// Each channel of the output color is clamped to the 0 to 1 range.
876 ///
877 /// @see `ColorMatrix`
878 Color ApplyColorMatrix(const ColorMatrix& color_matrix) const;
879
880 /// @brief Convert the color from linear space to sRGB space.
881 ///
882 /// The color is assumed to be unpremultiplied. If the color is
883 /// premultipled, the conversion output will be incorrect.
884 Color LinearToSRGB() const;
885
886 /// @brief Convert the color from sRGB space to linear space.
887 ///
888 /// The color is assumed to be unpremultiplied. If the color is
889 /// premultipled, the conversion output will be incorrect.
890 Color SRGBToLinear() const;
891
892 constexpr bool IsTransparent() const { return alpha == 0.0f; }
893
894 constexpr bool IsOpaque() const { return alpha == 1.0f; }
895 };
896
897 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
898 constexpr inline Color operator+(T value, const Color& c) {
899 return c + static_cast<Scalar>(value);
900 }
901
902 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
903 constexpr inline Color operator-(T value, const Color& c) {
904 auto v = static_cast<Scalar>(value);
905 return {v - c.red, v - c.green, v - c.blue, v - c.alpha};
906 }
907
908 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
909 constexpr inline Color operator*(T value, const Color& c) {
910 return c * static_cast<Scalar>(value);
911 }
912
913 template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
914 constexpr inline Color operator/(T value, const Color& c) {
915 auto v = static_cast<Scalar>(value);
916 return {v / c.red, v / c.green, v / c.blue, v / c.alpha};
917 }
918
919 std::string ColorToString(const Color& color);
920
921 static_assert(sizeof(Color) == 4 * sizeof(Scalar));
922
923 } // namespace impeller
924
925 namespace std {
926
927 inline std::ostream& operator<<(std::ostream& out, const impeller::Color& c) {
928 out << "(" << c.red << ", " << c.green << ", " << c.blue << ", " << c.alpha
929 << ")";
930 return out;
931 }
932
933 inline std::ostream& operator<<(std::ostream& out,
934 const impeller::BlendMode& mode) {
935 out << "BlendMode::k" << BlendModeToString(mode);
936 return out;
937 }
938
939 } // namespace std
940
941 #endif // FLUTTER_IMPELLER_GEOMETRY_COLOR_H_
value
int32_t value
Definition: dl_golden_unittests.cc:459
impeller::saturated::b
SI b
Definition: saturated_math.h:87
impeller
Definition: allocation.cc:12
impeller::YUVColorSpace
YUVColorSpace
Definition: color.h:54
impeller::YUVColorSpace::kBT601FullRange
@ kBT601FullRange
impeller::YUVColorSpace::kBT601LimitedRange
@ kBT601LimitedRange
impeller::operator-
constexpr Color operator-(T value, const Color &c)
Definition: color.h:903
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::operator/
constexpr Color operator/(T value, const Color &c)
Definition: color.h:914
impeller::operator+
constexpr Color operator+(T value, const Color &c)
Definition: color.h:898
impeller::BlendModeToString
const char * BlendModeToString(BlendMode blend_mode)
Definition: color.cc:47
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::BlendMode::kSrcOut
@ kSrcOut
impeller::BlendMode::kExclusion
@ kExclusion
impeller::BlendMode::kSaturation
@ kSaturation
impeller::BlendMode::kColorBurn
@ kColorBurn
impeller::BlendMode::kPlus
@ kPlus
impeller::BlendMode::kLighten
@ kLighten
impeller::BlendMode::kHue
@ kHue
impeller::BlendMode::kDst
@ kDst
impeller::BlendMode::kDstIn
@ kDstIn
impeller::BlendMode::kModulate
@ kModulate
impeller::BlendMode::kMultiply
@ kMultiply
impeller::BlendMode::kDefaultMode
@ kDefaultMode
impeller::BlendMode::kColorDodge
@ kColorDodge
impeller::BlendMode::kScreen
@ kScreen
impeller::BlendMode::kSrcOver
@ kSrcOver
impeller::BlendMode::kXor
@ kXor
impeller::BlendMode::kSrc
@ kSrc
impeller::BlendMode::kLuminosity
@ kLuminosity
impeller::BlendMode::kSoftLight
@ kSoftLight
impeller::BlendMode::kDifference
@ kDifference
impeller::BlendMode::kOverlay
@ kOverlay
impeller::BlendMode::kSrcATop
@ kSrcATop
impeller::BlendMode::kDstATop
@ kDstATop
impeller::BlendMode::kDstOver
@ kDstOver
impeller::BlendMode::kLastMode
@ kLastMode
impeller::BlendMode::kColor
@ kColor
impeller::BlendMode::kHardLight
@ kHardLight
impeller::BlendMode::kDstOut
@ kDstOut
impeller::BlendMode::kDarken
@ kDarken
impeller::BlendMode::kSrcIn
@ kSrcIn
impeller::BlendMode::kClear
@ kClear
impeller::operator*
constexpr Color operator*(T value, const Color &c)
Definition: color.h:909
impeller::ColorToString
std::string ColorToString(const Color &color)
Definition: color.cc:333
impeller::ScalarNearlyEqual
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
Definition: scalar.h:36
std
Definition: comparable.h:95
std::operator<<
std::ostream & operator<<(std::ostream &out, const impeller::Arc &a)
Definition: arc.h:141
scalar.h
impeller::Color
Definition: color.h:124
impeller::Color::MidnightBlue
static constexpr Color MidnightBlue()
Definition: color.h:654
impeller::Color::Crimson
static constexpr Color Crimson()
Definition: color.h:350
impeller::Color::SaddleBrown
static constexpr Color SaddleBrown()
Definition: color.h:754
impeller::Color::blue
Scalar blue
Definition: color.h:138
impeller::Color::Gray
static constexpr Color Gray()
Definition: color.h:486
impeller::Color::PapayaWhip
static constexpr Color PapayaWhip()
Definition: color.h:718
impeller::Color::ToR8G8B8A8
std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
Definition: color.h:246
impeller::Color::DarkCyan
static constexpr Color DarkCyan()
Definition: color.h:362
impeller::Color::Olive
static constexpr Color Olive()
Definition: color.h:682
impeller::Color::DarkTurquoise
static constexpr Color DarkTurquoise()
Definition: color.h:426
impeller::Color::SlateGray
static constexpr Color SlateGray()
Definition: color.h:790
impeller::Color::Moccasin
static constexpr Color Moccasin()
Definition: color.h:666
impeller::Color::MediumSeagreen
static constexpr Color MediumSeagreen()
Definition: color.h:634
impeller::Color::MediumBlue
static constexpr Color MediumBlue()
Definition: color.h:622
impeller::Color::LemonChiffon
static constexpr Color LemonChiffon()
Definition: color.h:534
impeller::Color::Cyan
static constexpr Color Cyan()
Definition: color.h:354
impeller::Color::operator*
constexpr Color operator*(T value) const
Definition: color.h:197
impeller::Color::Bisque
static constexpr Color Bisque()
Definition: color.h:306
impeller::Color::LightGrey
static constexpr Color LightGrey()
Definition: color.h:562
impeller::Color::ToIColor
static uint32_t ToIColor(Color color)
Convert this color to a 32-bit representation.
Definition: color.h:159
impeller::Color::DarkOrchid
static constexpr Color DarkOrchid()
Definition: color.h:398
impeller::Color::Lime
static constexpr Color Lime()
Definition: color.h:598
impeller::Color::DarkSalmon
static constexpr Color DarkSalmon()
Definition: color.h:406
impeller::Color::Grey
static constexpr Color Grey()
Definition: color.h:494
impeller::Color::ToARGB
uint32_t ToARGB() const
Convert to ARGB 32 bit color.
Definition: color.h:259
impeller::Color::IsOpaque
constexpr bool IsOpaque() const
Definition: color.h:894
impeller::Color::LightBlue
static constexpr Color LightBlue()
Definition: color.h:538
impeller::Color::LimeGreen
static constexpr Color LimeGreen()
Definition: color.h:602
impeller::Color::SandyBrown
static constexpr Color SandyBrown()
Definition: color.h:762
impeller::Color::LightSalmon
static constexpr Color LightSalmon()
Definition: color.h:570
impeller::Color::DarkOliveGreen
static constexpr Color DarkOliveGreen()
Definition: color.h:390
impeller::Color::PaleVioletRed
static constexpr Color PaleVioletRed()
Definition: color.h:714
impeller::Color::Azure
static constexpr Color Azure()
Definition: color.h:298
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:270
impeller::Color::GreenYellow
static constexpr Color GreenYellow()
Definition: color.h:490
impeller::Color::Thistle
static constexpr Color Thistle()
Definition: color.h:818
impeller::Color::LightPink
static constexpr Color LightPink()
Definition: color.h:566
impeller::Color::MistyRose
static constexpr Color MistyRose()
Definition: color.h:662
impeller::Color::MediumOrchid
static constexpr Color MediumOrchid()
Definition: color.h:626
impeller::Color::operator*
constexpr Color operator*(const Color &c) const
Definition: color.h:192
impeller::Color::DarkGoldenrod
static constexpr Color DarkGoldenrod()
Definition: color.h:366
impeller::Color::Indigo
static constexpr Color Indigo()
Definition: color.h:510
impeller::Color::Khaki
static constexpr Color Khaki()
Definition: color.h:518
impeller::Color::OldLace
static constexpr Color OldLace()
Definition: color.h:678
impeller::Color::DarkKhaki
static constexpr Color DarkKhaki()
Definition: color.h:382
impeller::Color::Honeydew
static constexpr Color Honeydew()
Definition: color.h:498
impeller::Color::RoyalBlue
static constexpr Color RoyalBlue()
Definition: color.h:750
impeller::Color::MintCream
static constexpr Color MintCream()
Definition: color.h:658
impeller::Color::operator/
constexpr Color operator/(T value) const
Definition: color.h:207
impeller::Color::Chartreuse
static constexpr Color Chartreuse()
Definition: color.h:330
impeller::Color::Orchid
static constexpr Color Orchid()
Definition: color.h:698
impeller::Color::alpha
Scalar alpha
Definition: color.h:143
impeller::Color::operator/
constexpr Color operator/(const Color &c) const
Definition: color.h:202
impeller::Color::BlueViolet
static constexpr Color BlueViolet()
Definition: color.h:314
impeller::Color::BurlyWood
static constexpr Color BurlyWood()
Definition: color.h:322
impeller::Color::Turquoise
static constexpr Color Turquoise()
Definition: color.h:826
impeller::Color::Fuchsia
static constexpr Color Fuchsia()
Definition: color.h:466
impeller::Color::Snow
static constexpr Color Snow()
Definition: color.h:798
impeller::Color::LightSteelBlue
static constexpr Color LightSteelBlue()
Definition: color.h:590
impeller::Color::operator==
constexpr bool operator==(const Color &c) const
Definition: color.h:167
impeller::Color::Seashell
static constexpr Color Seashell()
Definition: color.h:770
impeller::Color::LinearToSRGB
Color LinearToSRGB() const
Convert the color from linear space to sRGB space.
Definition: color.cc:311
impeller::Color::LightGray
static constexpr Color LightGray()
Definition: color.h:554
impeller::Color::DeepPink
static constexpr Color DeepPink()
Definition: color.h:434
impeller::Color::Black
static constexpr Color Black()
Definition: color.h:266
impeller::Color::IndianRed
static constexpr Color IndianRed()
Definition: color.h:506
impeller::Color::Ivory
static constexpr Color Ivory()
Definition: color.h:514
impeller::Color::DarkBlue
static constexpr Color DarkBlue()
Definition: color.h:358
impeller::Color::CornflowerBlue
static constexpr Color CornflowerBlue()
Definition: color.h:342
impeller::Color::LightSkyBlue
static constexpr Color LightSkyBlue()
Definition: color.h:578
impeller::Color::operator+
constexpr Color operator+(T value) const
Definition: color.h:177
impeller::Color::Violet
static constexpr Color Violet()
Definition: color.h:830
impeller::Color::Sienna
static constexpr Color Sienna()
Definition: color.h:774
impeller::Color::Chocolate
static constexpr Color Chocolate()
Definition: color.h:334
impeller::Color::MediumTurquoise
static constexpr Color MediumTurquoise()
Definition: color.h:646
impeller::Color::White
static constexpr Color White()
Definition: color.h:264
impeller::Color::Gold
static constexpr Color Gold()
Definition: color.h:478
impeller::Color::Navy
static constexpr Color Navy()
Definition: color.h:674
impeller::Color::IsTransparent
constexpr bool IsTransparent() const
Definition: color.h:892
impeller::Color::SlateBlue
static constexpr Color SlateBlue()
Definition: color.h:786
impeller::Color::Beige
static constexpr Color Beige()
Definition: color.h:302
impeller::Color::LawnGreen
static constexpr Color LawnGreen()
Definition: color.h:530
impeller::Color::Magenta
static constexpr Color Magenta()
Definition: color.h:610
impeller::Color::PaleGreen
static constexpr Color PaleGreen()
Definition: color.h:706
impeller::Color::CadetBlue
static constexpr Color CadetBlue()
Definition: color.h:326
impeller::Color::DodgerBlue
static constexpr Color DodgerBlue()
Definition: color.h:450
impeller::Color::LightCoral
static constexpr Color LightCoral()
Definition: color.h:542
impeller::Color::WithAlpha
constexpr Color WithAlpha(Scalar new_alpha) const
Definition: color.h:278
impeller::Color::LavenderBlush
static constexpr Color LavenderBlush()
Definition: color.h:526
impeller::Color::DarkGrey
static constexpr Color DarkGrey()
Definition: color.h:378
impeller::Color::PowderBlue
static constexpr Color PowderBlue()
Definition: color.h:738
impeller::Color::ApplyColorMatrix
Color ApplyColorMatrix(const ColorMatrix &color_matrix) const
A color filter that transforms colors through a 4x5 color matrix.
Definition: color.cc:301
impeller::Color::WhiteTransparent
static constexpr Color WhiteTransparent()
Definition: color.h:268
impeller::Color::HotPink
static constexpr Color HotPink()
Definition: color.h:502
impeller::Color::Color
constexpr Color(Scalar r, Scalar g, Scalar b, Scalar a)
Definition: color.h:149
impeller::Color::SkyBlue
static constexpr Color SkyBlue()
Definition: color.h:782
impeller::Color::SpringGreen
static constexpr Color SpringGreen()
Definition: color.h:802
impeller::Color::BlanchedAlmond
static constexpr Color BlanchedAlmond()
Definition: color.h:310
impeller::Color::LightSlateGray
static constexpr Color LightSlateGray()
Definition: color.h:582
impeller::Color::operator+
constexpr Color operator+(const Color &c) const
Definition: color.h:172
impeller::Color::DimGrey
static constexpr Color DimGrey()
Definition: color.h:446
impeller::Color::Maroon
static constexpr Color Maroon()
Definition: color.h:614
impeller::Color::Ghostwhite
static constexpr Color Ghostwhite()
Definition: color.h:474
impeller::Color::OrangeRed
static constexpr Color OrangeRed()
Definition: color.h:694
impeller::Color::MediumAquamarine
static constexpr Color MediumAquamarine()
Definition: color.h:618
impeller::Color::DeepSkyBlue
static constexpr Color DeepSkyBlue()
Definition: color.h:438
impeller::Color::DarkGreen
static constexpr Color DarkGreen()
Definition: color.h:374
impeller::Color::Orange
static constexpr Color Orange()
Definition: color.h:690
impeller::Color::Teal
static constexpr Color Teal()
Definition: color.h:814
impeller::Color::Purple
static constexpr Color Purple()
Definition: color.h:742
impeller::Color::red
Scalar red
Definition: color.h:128
impeller::Color::Wheat
static constexpr Color Wheat()
Definition: color.h:834
impeller::Color::Cornsilk
static constexpr Color Cornsilk()
Definition: color.h:346
impeller::Color::Aqua
static constexpr Color Aqua()
Definition: color.h:290
impeller::Color::Tan
static constexpr Color Tan()
Definition: color.h:810
impeller::Color::Coral
static constexpr Color Coral()
Definition: color.h:338
impeller::Color::Red
static constexpr Color Red()
Definition: color.h:272
impeller::Color::PaleTurquoise
static constexpr Color PaleTurquoise()
Definition: color.h:710
impeller::Color::Unpremultiply
constexpr Color Unpremultiply() const
Definition: color.h:216
impeller::Color::Color
constexpr Color()
Definition: color.h:145
impeller::Color::LightGoldenrodYellow
static constexpr Color LightGoldenrodYellow()
Definition: color.h:550
impeller::Color::LightYellow
static constexpr Color LightYellow()
Definition: color.h:594
impeller::Color::SteelBlue
static constexpr Color SteelBlue()
Definition: color.h:806
impeller::Color::green
Scalar green
Definition: color.h:133
impeller::Color::DarkRed
static constexpr Color DarkRed()
Definition: color.h:402
impeller::Color::MediumSpringGreen
static constexpr Color MediumSpringGreen()
Definition: color.h:642
impeller::Color::MediumPurple
static constexpr Color MediumPurple()
Definition: color.h:630
impeller::Color::Premultiply
constexpr Color Premultiply() const
Definition: color.h:212
impeller::Color::Firebrick
static constexpr Color Firebrick()
Definition: color.h:454
impeller::Color::LightGreen
static constexpr Color LightGreen()
Definition: color.h:558
impeller::Color::Pink
static constexpr Color Pink()
Definition: color.h:730
impeller::Color::DarkOrange
static constexpr Color DarkOrange()
Definition: color.h:394
impeller::Color::ForestGreen
static constexpr Color ForestGreen()
Definition: color.h:462
impeller::Color::Silver
static constexpr Color Silver()
Definition: color.h:778
impeller::Color::Brown
static constexpr Color Brown()
Definition: color.h:318
impeller::Color::Gainsboro
static constexpr Color Gainsboro()
Definition: color.h:470
impeller::Color::Peachpuff
static constexpr Color Peachpuff()
Definition: color.h:722
impeller::Color::MediumSlateBlue
static constexpr Color MediumSlateBlue()
Definition: color.h:638
impeller::Color::Seagreen
static constexpr Color Seagreen()
Definition: color.h:766
impeller::Color::AliceBlue
static constexpr Color AliceBlue()
Definition: color.h:282
impeller::Color::Salmon
static constexpr Color Salmon()
Definition: color.h:758
impeller::Color::Random
static Color Random()
Definition: color.h:850
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::DarkSlateBlue
static constexpr Color DarkSlateBlue()
Definition: color.h:414
impeller::Color::AquaMarine
static constexpr Color AquaMarine()
Definition: color.h:294
impeller::Color::operator-
constexpr Color operator-(T value) const
Definition: color.h:187
impeller::Color::AntiqueWhite
static constexpr Color AntiqueWhite()
Definition: color.h:286
impeller::Color::Lavender
static constexpr Color Lavender()
Definition: color.h:522
impeller::Color::Plum
static constexpr Color Plum()
Definition: color.h:734
impeller::Color::LightSeaGreen
static constexpr Color LightSeaGreen()
Definition: color.h:574
impeller::Color::DarkSeagreen
static constexpr Color DarkSeagreen()
Definition: color.h:410
impeller::Color::NavajoWhite
static constexpr Color NavajoWhite()
Definition: color.h:670
impeller::Color::Clamp01
constexpr Color Clamp01() const
Definition: color.h:236
impeller::Color::LightCyan
static constexpr Color LightCyan()
Definition: color.h:546
impeller::Color::DimGray
static constexpr Color DimGray()
Definition: color.h:442
impeller::Color::Tomato
static constexpr Color Tomato()
Definition: color.h:822
impeller::Color::FloralWhite
static constexpr Color FloralWhite()
Definition: color.h:458
impeller::Color::Linen
static constexpr Color Linen()
Definition: color.h:606
impeller::Color::YellowGreen
static constexpr Color YellowGreen()
Definition: color.h:846
impeller::Color::DarkSlateGrey
static constexpr Color DarkSlateGrey()
Definition: color.h:422
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::DarkGray
static constexpr Color DarkGray()
Definition: color.h:370
impeller::Color::DarkMagenta
static constexpr Color DarkMagenta()
Definition: color.h:386
impeller::Color::Yellow
static constexpr Color Yellow()
Definition: color.h:842
impeller::Color::Goldenrod
static constexpr Color Goldenrod()
Definition: color.h:482
impeller::Color::SRGBToLinear
Color SRGBToLinear() const
Convert the color from sRGB space to linear space.
Definition: color.cc:322
impeller::Color::Peru
static constexpr Color Peru()
Definition: color.h:726
impeller::Color::MediumVioletRed
static constexpr Color MediumVioletRed()
Definition: color.h:650
impeller::Color::SlateGrey
static constexpr Color SlateGrey()
Definition: color.h:794
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:157
impeller::Color::LightSlateGrey
static constexpr Color LightSlateGrey()
Definition: color.h:586
impeller::Color::operator-
constexpr Color operator-(const Color &c) const
Definition: color.h:182
impeller::Color::DarkViolet
static constexpr Color DarkViolet()
Definition: color.h:430
impeller::Color::OliveDrab
static constexpr Color OliveDrab()
Definition: color.h:686
impeller::Color::PaleGoldenrod
static constexpr Color PaleGoldenrod()
Definition: color.h:702
impeller::Color::RosyBrown
static constexpr Color RosyBrown()
Definition: color.h:746
impeller::Color::Blue
static constexpr Color Blue()
Definition: color.h:276
impeller::Color::Green
static constexpr Color Green()
Definition: color.h:274
impeller::Color::DarkSlateGray
static constexpr Color DarkSlateGray()
Definition: color.h:418
impeller::Color::Whitesmoke
static constexpr Color Whitesmoke()
Definition: color.h:838
impeller::ColorMatrix
Definition: color.h:117
impeller::ColorMatrix::array
Scalar array[20]
Definition: color.h:118
impeller::Vector4
Definition: vector.h:232
type_traits.h