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