Flutter Impeller
impeller::Color Struct Reference

#include <color.h>

Public Member Functions

constexpr Color ()
 
 Color (const ColorHSB &hsbColor)
 
 Color (const Vector4 &value)
 
constexpr Color (Scalar r, Scalar g, Scalar b, Scalar a)
 
constexpr bool operator== (const Color &c) const
 
constexpr Color operator+ (const Color &c) const
 
template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color operator+ (T value) const
 
constexpr Color operator- (const Color &c) const
 
template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color operator- (T value) const
 
constexpr Color operator* (const Color &c) const
 
template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color operator* (T value) const
 
constexpr Color operator/ (const Color &c) const
 
template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color operator/ (T value) const
 
constexpr Color Premultiply () const
 
constexpr Color Unpremultiply () const
 
constexpr Color Clamp01 () const
 
constexpr std::array< uint8_t, 4 > ToR8G8B8A8 () const
 Convert to R8G8B8A8 representation. More...
 
constexpr Color WithAlpha (Scalar new_alpha) const
 
Color Blend (Color source, BlendMode blend_mode) const
 Blends an unpremultiplied destination color into a given unpremultiplied source color to form a new unpremultiplied color. More...
 
Color ApplyColorMatrix (const ColorMatrix &color_matrix) const
 A color filter that transforms colors through a 4x5 color matrix. More...
 
Color LinearToSRGB () const
 Convert the color from linear space to sRGB space. More...
 
Color SRGBToLinear () const
 Convert the color from sRGB space to linear space. More...
 
constexpr bool IsTransparent () const
 
constexpr bool IsOpaque () const
 

Static Public Member Functions

static constexpr Color MakeRGBA8 (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 
static constexpr uint32_t ToIColor (Color color)
 Convert this color to a 32-bit representation. More...
 
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. More...
 
static constexpr Color White ()
 
static constexpr Color Black ()
 
static constexpr Color WhiteTransparent ()
 
static constexpr Color BlackTransparent ()
 
static constexpr Color Red ()
 
static constexpr Color Green ()
 
static constexpr Color Blue ()
 
static constexpr Color AliceBlue ()
 
static constexpr Color AntiqueWhite ()
 
static constexpr Color Aqua ()
 
static constexpr Color AquaMarine ()
 
static constexpr Color Azure ()
 
static constexpr Color Beige ()
 
static constexpr Color Bisque ()
 
static constexpr Color BlanchedAlmond ()
 
static constexpr Color BlueViolet ()
 
static constexpr Color Brown ()
 
static constexpr Color BurlyWood ()
 
static constexpr Color CadetBlue ()
 
static constexpr Color Chartreuse ()
 
static constexpr Color Chocolate ()
 
static constexpr Color Coral ()
 
static constexpr Color CornflowerBlue ()
 
static constexpr Color Cornsilk ()
 
static constexpr Color Crimson ()
 
static constexpr Color Cyan ()
 
static constexpr Color DarkBlue ()
 
static constexpr Color DarkCyan ()
 
static constexpr Color DarkGoldenrod ()
 
static constexpr Color DarkGray ()
 
static constexpr Color DarkGreen ()
 
static constexpr Color DarkGrey ()
 
static constexpr Color DarkKhaki ()
 
static constexpr Color DarkMagenta ()
 
static constexpr Color DarkOliveGreen ()
 
static constexpr Color DarkOrange ()
 
static constexpr Color DarkOrchid ()
 
static constexpr Color DarkRed ()
 
static constexpr Color DarkSalmon ()
 
static constexpr Color DarkSeagreen ()
 
static constexpr Color DarkSlateBlue ()
 
static constexpr Color DarkSlateGray ()
 
static constexpr Color DarkSlateGrey ()
 
static constexpr Color DarkTurquoise ()
 
static constexpr Color DarkViolet ()
 
static constexpr Color DeepPink ()
 
static constexpr Color DeepSkyBlue ()
 
static constexpr Color DimGray ()
 
static constexpr Color DimGrey ()
 
static constexpr Color DodgerBlue ()
 
static constexpr Color Firebrick ()
 
static constexpr Color FloralWhite ()
 
static constexpr Color ForestGreen ()
 
static constexpr Color Fuchsia ()
 
static constexpr Color Gainsboro ()
 
static constexpr Color Ghostwhite ()
 
static constexpr Color Gold ()
 
static constexpr Color Goldenrod ()
 
static constexpr Color Gray ()
 
static constexpr Color GreenYellow ()
 
static constexpr Color Grey ()
 
static constexpr Color Honeydew ()
 
static constexpr Color HotPink ()
 
static constexpr Color IndianRed ()
 
static constexpr Color Indigo ()
 
static constexpr Color Ivory ()
 
static constexpr Color Khaki ()
 
static constexpr Color Lavender ()
 
static constexpr Color LavenderBlush ()
 
static constexpr Color LawnGreen ()
 
static constexpr Color LemonChiffon ()
 
static constexpr Color LightBlue ()
 
static constexpr Color LightCoral ()
 
static constexpr Color LightCyan ()
 
static constexpr Color LightGoldenrodYellow ()
 
static constexpr Color LightGray ()
 
static constexpr Color LightGreen ()
 
static constexpr Color LightGrey ()
 
static constexpr Color LightPink ()
 
static constexpr Color LightSalmon ()
 
static constexpr Color LightSeaGreen ()
 
static constexpr Color LightSkyBlue ()
 
static constexpr Color LightSlateGray ()
 
static constexpr Color LightSlateGrey ()
 
static constexpr Color LightSteelBlue ()
 
static constexpr Color LightYellow ()
 
static constexpr Color Lime ()
 
static constexpr Color LimeGreen ()
 
static constexpr Color Linen ()
 
static constexpr Color Magenta ()
 
static constexpr Color Maroon ()
 
static constexpr Color MediumAquamarine ()
 
static constexpr Color MediumBlue ()
 
static constexpr Color MediumOrchid ()
 
static constexpr Color MediumPurple ()
 
static constexpr Color MediumSeagreen ()
 
static constexpr Color MediumSlateBlue ()
 
static constexpr Color MediumSpringGreen ()
 
static constexpr Color MediumTurquoise ()
 
static constexpr Color MediumVioletRed ()
 
static constexpr Color MidnightBlue ()
 
static constexpr Color MintCream ()
 
static constexpr Color MistyRose ()
 
static constexpr Color Moccasin ()
 
static constexpr Color NavajoWhite ()
 
static constexpr Color Navy ()
 
static constexpr Color OldLace ()
 
static constexpr Color Olive ()
 
static constexpr Color OliveDrab ()
 
static constexpr Color Orange ()
 
static constexpr Color OrangeRed ()
 
static constexpr Color Orchid ()
 
static constexpr Color PaleGoldenrod ()
 
static constexpr Color PaleGreen ()
 
static constexpr Color PaleTurquoise ()
 
static constexpr Color PaleVioletRed ()
 
static constexpr Color PapayaWhip ()
 
static constexpr Color Peachpuff ()
 
static constexpr Color Peru ()
 
static constexpr Color Pink ()
 
static constexpr Color Plum ()
 
static constexpr Color PowderBlue ()
 
static constexpr Color Purple ()
 
static constexpr Color RosyBrown ()
 
static constexpr Color RoyalBlue ()
 
static constexpr Color SaddleBrown ()
 
static constexpr Color Salmon ()
 
static constexpr Color SandyBrown ()
 
static constexpr Color Seagreen ()
 
static constexpr Color Seashell ()
 
static constexpr Color Sienna ()
 
static constexpr Color Silver ()
 
static constexpr Color SkyBlue ()
 
static constexpr Color SlateBlue ()
 
static constexpr Color SlateGray ()
 
static constexpr Color SlateGrey ()
 
static constexpr Color Snow ()
 
static constexpr Color SpringGreen ()
 
static constexpr Color SteelBlue ()
 
static constexpr Color Tan ()
 
static constexpr Color Teal ()
 
static constexpr Color Thistle ()
 
static constexpr Color Tomato ()
 
static constexpr Color Turquoise ()
 
static constexpr Color Violet ()
 
static constexpr Color Wheat ()
 
static constexpr Color Whitesmoke ()
 
static constexpr Color Yellow ()
 
static constexpr Color YellowGreen ()
 
static Color Random ()
 

Public Attributes

Scalar red = 0.0
 
Scalar green = 0.0
 
Scalar blue = 0.0
 
Scalar alpha = 0.0
 

Detailed Description

Represents a RGBA color

Definition at line 122 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/4]

constexpr impeller::Color::Color ( )
inlineconstexpr

Definition at line 143 of file color.h.

143 {}

Referenced by ApplyColorMatrix(), Clamp01(), LinearToSRGB(), MakeRGBA8(), and SRGBToLinear().

◆ Color() [2/4]

impeller::Color::Color ( const ColorHSB hsbColor)
explicit

Definition at line 127 of file color.cc.

127 : Color(hsbColor.ToRGBA()) {}

◆ Color() [3/4]

impeller::Color::Color ( const Vector4 value)
explicit

Definition at line 129 of file color.cc.

130  : red(value.x), green(value.y), blue(value.z), alpha(value.w) {}

◆ Color() [4/4]

constexpr impeller::Color::Color ( Scalar  r,
Scalar  g,
Scalar  b,
Scalar  a 
)
inlineconstexpr

Definition at line 149 of file color.h.

150  : red(r), green(g), blue(b), alpha(a) {}

Member Function Documentation

◆ AliceBlue()

static constexpr Color impeller::Color::AliceBlue ( )
inlinestaticconstexpr

Definition at line 272 of file color.h.

272  {
273  return {240.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
274  }

Referenced by impeller::testing::TEST_P().

◆ AntiqueWhite()

static constexpr Color impeller::Color::AntiqueWhite ( )
inlinestaticconstexpr

Definition at line 276 of file color.h.

276  {
277  return {250.0f / 255.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f};
278  }

◆ ApplyColorMatrix()

Color impeller::Color::ApplyColorMatrix ( const ColorMatrix color_matrix) const

A color filter that transforms colors through a 4x5 color matrix.

   This filter can be used to change the saturation of pixels, convert
   from YUV to RGB, etc.

   Each channel of the output color is clamped to the 0 to 1 range.
See also
ColorMatrix

Definition at line 366 of file color.cc.

366  {
367  auto* c = color_matrix.array;
368  return Color(
369  c[0] * red + c[1] * green + c[2] * blue + c[3] * alpha + c[4],
370  c[5] * red + c[6] * green + c[7] * blue + c[8] * alpha + c[9],
371  c[10] * red + c[11] * green + c[12] * blue + c[13] * alpha + c[14],
372  c[15] * red + c[16] * green + c[17] * blue + c[18] * alpha + c[19])
373  .Clamp01();
374 }

References alpha, impeller::ColorMatrix::array, blue, Color(), green, and red.

Referenced by impeller::testing::TEST().

◆ Aqua()

static constexpr Color impeller::Color::Aqua ( )
inlinestaticconstexpr

Definition at line 280 of file color.h.

280  {
281  return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
282  }

◆ AquaMarine()

static constexpr Color impeller::Color::AquaMarine ( )
inlinestaticconstexpr

Definition at line 284 of file color.h.

284  {
285  return {127.0f / 255.0f, 255.0f / 255.0f, 212.0f / 255.0f, 1.0f};
286  }

◆ Azure()

static constexpr Color impeller::Color::Azure ( )
inlinestaticconstexpr

Definition at line 288 of file color.h.

288  {
289  return {240.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
290  }

◆ Beige()

static constexpr Color impeller::Color::Beige ( )
inlinestaticconstexpr

Definition at line 292 of file color.h.

292  {
293  return {245.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f, 1.0f};
294  }

◆ Bisque()

static constexpr Color impeller::Color::Bisque ( )
inlinestaticconstexpr

Definition at line 296 of file color.h.

296  {
297  return {255.0f / 255.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f};
298  }

◆ Black()

static constexpr Color impeller::Color::Black ( )
inlinestaticconstexpr

Definition at line 256 of file color.h.

256 { return {0.0f, 0.0f, 0.0f, 1.0f}; }

Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ BlackTransparent()

static constexpr Color impeller::Color::BlackTransparent ( )
inlinestaticconstexpr

Definition at line 260 of file color.h.

260 { return {0.0f, 0.0f, 0.0f, 0.0f}; }

Referenced by Blend(), impeller::testing::TEST(), impeller::testing::TEST_P(), and Unpremultiply().

◆ BlanchedAlmond()

static constexpr Color impeller::Color::BlanchedAlmond ( )
inlinestaticconstexpr

Definition at line 300 of file color.h.

300  {
301  return {255.0f / 255.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f};
302  }

◆ Blend()

Color impeller::Color::Blend ( Color  source,
BlendMode  blend_mode 
) const

Blends an unpremultiplied destination color into a given unpremultiplied source color to form a new unpremultiplied color.

If either the source or destination are premultiplied, the result will be incorrect.

Definition at line 222 of file color.cc.

222  {
223  Color dst = *this;
224 
225  switch (blend_mode) {
226  case BlendMode::kClear:
227  return Color::BlackTransparent();
228  case BlendMode::kSource:
229  return src;
231  return dst;
233  // r = s + (1-sa)*d
234  return (src.Premultiply() + dst.Premultiply() * (1 - src.alpha))
235  .Unpremultiply();
237  // r = d + (1-da)*s
238  return (dst.Premultiply() + src.Premultiply() * (1 - dst.alpha))
239  .Unpremultiply();
241  // r = s * da
242  return (src.Premultiply() * dst.alpha).Unpremultiply();
244  // r = d * sa
245  return (dst.Premultiply() * src.alpha).Unpremultiply();
247  // r = s * ( 1- da)
248  return (src.Premultiply() * (1 - dst.alpha)).Unpremultiply();
250  // r = d * (1-sa)
251  return (dst.Premultiply() * (1 - src.alpha)).Unpremultiply();
253  // r = s*da + d*(1-sa)
254  return (src.Premultiply() * dst.alpha +
255  dst.Premultiply() * (1 - src.alpha))
256  .Unpremultiply();
258  // r = d*sa + s*(1-da)
259  return (dst.Premultiply() * src.alpha +
260  src.Premultiply() * (1 - dst.alpha))
261  .Unpremultiply();
262  case BlendMode::kXor:
263  // r = s*(1-da) + d*(1-sa)
264  return (src.Premultiply() * (1 - dst.alpha) +
265  dst.Premultiply() * (1 - src.alpha))
266  .Unpremultiply();
267  case BlendMode::kPlus:
268  // r = min(s + d, 1)
269  return (Min(src.Premultiply() + dst.Premultiply(), 1)).Unpremultiply();
271  // r = s*d
272  return (src.Premultiply() * dst.Premultiply()).Unpremultiply();
273  case BlendMode::kScreen: {
274  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
275  return s + d - s * d;
276  });
277  }
278  case BlendMode::kOverlay:
279  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
280  // The same as HardLight, but with the source and destination reversed.
281  Vector3 screen_src = 2.0 * d - 1.0;
282  Vector3 screen = screen_src + s - screen_src * s;
283  return ComponentChoose(s * (2.0 * d), //
284  screen, //
285  d, //
286  0.5);
287  });
288  case BlendMode::kDarken:
289  return DoColorBlend(
290  dst, src, [](Vector3 d, Vector3 s) -> Vector3 { return d.Min(s); });
291  case BlendMode::kLighten:
292  return DoColorBlend(
293  dst, src, [](Vector3 d, Vector3 s) -> Vector3 { return d.Max(s); });
295  return DoColorBlendComponents(dst, src, [](Scalar d, Scalar s) -> Scalar {
296  if (d < kEhCloseEnough) {
297  return 0.0f;
298  }
299  if (1.0 - s < kEhCloseEnough) {
300  return 1.0f;
301  }
302  return std::min(1.0f, d / (1.0f - s));
303  });
305  return DoColorBlendComponents(dst, src, [](Scalar d, Scalar s) -> Scalar {
306  if (1.0 - d < kEhCloseEnough) {
307  return 1.0f;
308  }
309  if (s < kEhCloseEnough) {
310  return 0.0f;
311  }
312  return 1.0f - std::min(1.0f, (1.0f - d) / s);
313  });
315  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
316  Vector3 screen_src = 2.0 * s - 1.0;
317  Vector3 screen = screen_src + d - screen_src * d;
318  return ComponentChoose(d * (2.0 * s), //
319  screen, //
320  s, //
321  0.5);
322  });
324  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
325  Vector3 D = ComponentChoose(((16.0 * d - 12.0) * d + 4.0) * d, //
326  Vector3(std::sqrt(d.x), std::sqrt(d.y),
327  std::sqrt(d.z)), //
328  d, //
329  0.25);
330  return ComponentChoose(d - (1.0 - 2.0 * s) * d * (1.0 - d), //
331  d + (2.0 * s - 1.0) * (D - d), //
332  s, //
333  0.5);
334  });
336  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
337  return (d - s).Abs();
338  });
340  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
341  return d + s - 2.0f * d * s;
342  });
344  return DoColorBlend(
345  dst, src, [](Vector3 d, Vector3 s) -> Vector3 { return d * s; });
346  case BlendMode::kHue: {
347  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
349  });
350  }
352  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
354  });
355  case BlendMode::kColor:
356  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
357  return SetLuminosity(s, Luminosity(d));
358  });
360  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
361  return SetLuminosity(d, Luminosity(s));
362  });
363  }
364 }

References alpha, BlackTransparent(), impeller::ComponentChoose(), impeller::DoColorBlend(), impeller::DoColorBlendComponents(), impeller::kClear, impeller::kColor, impeller::kColorBurn, impeller::kColorDodge, impeller::kDarken, impeller::kDestination, impeller::kDestinationATop, impeller::kDestinationIn, impeller::kDestinationOut, impeller::kDestinationOver, impeller::kDifference, impeller::kEhCloseEnough, impeller::kExclusion, impeller::kHardLight, impeller::kHue, impeller::kLighten, impeller::kLuminosity, impeller::kModulate, impeller::kMultiply, impeller::kOverlay, impeller::kPlus, impeller::kSaturation, impeller::kScreen, impeller::kSoftLight, impeller::kSource, impeller::kSourceATop, impeller::kSourceIn, impeller::kSourceOut, impeller::kSourceOver, impeller::kXor, impeller::Luminosity(), impeller::Vector3::Max(), impeller::Vector3::Min(), impeller::Min(), Premultiply(), impeller::Saturation(), impeller::SetLuminosity(), impeller::SetSaturation(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.

Referenced by impeller::testing::BlendModeTest(), impeller::EntityPass::GetClearColor(), and impeller::testing::TEST_P().

◆ Blue()

static constexpr Color impeller::Color::Blue ( )
inlinestaticconstexpr

Definition at line 266 of file color.h.

266 { return {0.0f, 0.0f, 1.0f, 1.0f}; }

Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ BlueViolet()

static constexpr Color impeller::Color::BlueViolet ( )
inlinestaticconstexpr

Definition at line 304 of file color.h.

304  {
305  return {138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f};
306  }

◆ Brown()

static constexpr Color impeller::Color::Brown ( )
inlinestaticconstexpr

Definition at line 308 of file color.h.

308  {
309  return {165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f};
310  }

◆ BurlyWood()

static constexpr Color impeller::Color::BurlyWood ( )
inlinestaticconstexpr

Definition at line 312 of file color.h.

312  {
313  return {222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f};
314  }

◆ CadetBlue()

static constexpr Color impeller::Color::CadetBlue ( )
inlinestaticconstexpr

Definition at line 316 of file color.h.

316  {
317  return {95.0f / 255.0f, 158.0f / 255.0f, 160.0f / 255.0f, 1.0f};
318  }

◆ Chartreuse()

static constexpr Color impeller::Color::Chartreuse ( )
inlinestaticconstexpr

Definition at line 320 of file color.h.

320  {
321  return {127.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
322  }

◆ Chocolate()

static constexpr Color impeller::Color::Chocolate ( )
inlinestaticconstexpr

Definition at line 324 of file color.h.

324  {
325  return {210.0f / 255.0f, 105.0f / 255.0f, 30.0f / 255.0f, 1.0f};
326  }

◆ Clamp01()

constexpr Color impeller::Color::Clamp01 ( ) const
inlineconstexpr

Definition at line 236 of file color.h.

236  {
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  }

References alpha, blue, Color(), green, and red.

Referenced by impeller::testing::TEST().

◆ Coral()

static constexpr Color impeller::Color::Coral ( )
inlinestaticconstexpr

Definition at line 328 of file color.h.

328  {
329  return {255.0f / 255.0f, 127.0f / 255.0f, 80.0f / 255.0f, 1.0f};
330  }

Referenced by impeller::testing::TEST_P().

◆ CornflowerBlue()

static constexpr Color impeller::Color::CornflowerBlue ( )
inlinestaticconstexpr

Definition at line 332 of file color.h.

332  {
333  return {100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f};
334  }

Referenced by impeller::testing::TEST_P().

◆ Cornsilk()

static constexpr Color impeller::Color::Cornsilk ( )
inlinestaticconstexpr

Definition at line 336 of file color.h.

336  {
337  return {255.0f / 255.0f, 248.0f / 255.0f, 220.0f / 255.0f, 1.0f};
338  }

◆ Crimson()

static constexpr Color impeller::Color::Crimson ( )
inlinestaticconstexpr

Definition at line 340 of file color.h.

340  {
341  return {220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f};
342  }

◆ Cyan()

static constexpr Color impeller::Color::Cyan ( )
inlinestaticconstexpr

Definition at line 344 of file color.h.

344  {
345  return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
346  }

◆ DarkBlue()

static constexpr Color impeller::Color::DarkBlue ( )
inlinestaticconstexpr

Definition at line 348 of file color.h.

348  {
349  return {0.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
350  }

◆ DarkCyan()

static constexpr Color impeller::Color::DarkCyan ( )
inlinestaticconstexpr

Definition at line 352 of file color.h.

352  {
353  return {0.0f / 255.0f, 139.0f / 255.0f, 139.0f / 255.0f, 1.0f};
354  }

◆ DarkGoldenrod()

static constexpr Color impeller::Color::DarkGoldenrod ( )
inlinestaticconstexpr

Definition at line 356 of file color.h.

356  {
357  return {184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f};
358  }

◆ DarkGray()

static constexpr Color impeller::Color::DarkGray ( )
inlinestaticconstexpr

Definition at line 360 of file color.h.

360  {
361  return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
362  }

◆ DarkGreen()

static constexpr Color impeller::Color::DarkGreen ( )
inlinestaticconstexpr

Definition at line 364 of file color.h.

364  {
365  return {0.0f / 255.0f, 100.0f / 255.0f, 0.0f / 255.0f, 1.0f};
366  }

◆ DarkGrey()

static constexpr Color impeller::Color::DarkGrey ( )
inlinestaticconstexpr

Definition at line 368 of file color.h.

368  {
369  return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
370  }

◆ DarkKhaki()

static constexpr Color impeller::Color::DarkKhaki ( )
inlinestaticconstexpr

Definition at line 372 of file color.h.

372  {
373  return {189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f};
374  }

◆ DarkMagenta()

static constexpr Color impeller::Color::DarkMagenta ( )
inlinestaticconstexpr

Definition at line 376 of file color.h.

376  {
377  return {139.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
378  }

◆ DarkOliveGreen()

static constexpr Color impeller::Color::DarkOliveGreen ( )
inlinestaticconstexpr

Definition at line 380 of file color.h.

380  {
381  return {85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f};
382  }

◆ DarkOrange()

static constexpr Color impeller::Color::DarkOrange ( )
inlinestaticconstexpr

Definition at line 384 of file color.h.

384  {
385  return {255.0f / 255.0f, 140.0f / 255.0f, 0.0f / 255.0f, 1.0f};
386  }

◆ DarkOrchid()

static constexpr Color impeller::Color::DarkOrchid ( )
inlinestaticconstexpr

Definition at line 388 of file color.h.

388  {
389  return {153.0f / 255.0f, 50.0f / 255.0f, 204.0f / 255.0f, 1.0f};
390  }

◆ DarkRed()

static constexpr Color impeller::Color::DarkRed ( )
inlinestaticconstexpr

Definition at line 392 of file color.h.

392  {
393  return {139.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
394  }

◆ DarkSalmon()

static constexpr Color impeller::Color::DarkSalmon ( )
inlinestaticconstexpr

Definition at line 396 of file color.h.

396  {
397  return {233.0f / 255.0f, 150.0f / 255.0f, 122.0f / 255.0f, 1.0f};
398  }

◆ DarkSeagreen()

static constexpr Color impeller::Color::DarkSeagreen ( )
inlinestaticconstexpr

Definition at line 400 of file color.h.

400  {
401  return {143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f};
402  }

◆ DarkSlateBlue()

static constexpr Color impeller::Color::DarkSlateBlue ( )
inlinestaticconstexpr

Definition at line 404 of file color.h.

404  {
405  return {72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f};
406  }

◆ DarkSlateGray()

static constexpr Color impeller::Color::DarkSlateGray ( )
inlinestaticconstexpr

Definition at line 408 of file color.h.

408  {
409  return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
410  }

Referenced by impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), and impeller::WrapTextureWithRenderTarget().

◆ DarkSlateGrey()

static constexpr Color impeller::Color::DarkSlateGrey ( )
inlinestaticconstexpr

Definition at line 412 of file color.h.

412  {
413  return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
414  }

◆ DarkTurquoise()

static constexpr Color impeller::Color::DarkTurquoise ( )
inlinestaticconstexpr

Definition at line 416 of file color.h.

416  {
417  return {0.0f / 255.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f};
418  }

◆ DarkViolet()

static constexpr Color impeller::Color::DarkViolet ( )
inlinestaticconstexpr

Definition at line 420 of file color.h.

420  {
421  return {148.0f / 255.0f, 0.0f / 255.0f, 211.0f / 255.0f, 1.0f};
422  }

◆ DeepPink()

static constexpr Color impeller::Color::DeepPink ( )
inlinestaticconstexpr

Definition at line 424 of file color.h.

424  {
425  return {255.0f / 255.0f, 20.0f / 255.0f, 147.0f / 255.0f, 1.0f};
426  }

Referenced by impeller::testing::TEST_P().

◆ DeepSkyBlue()

static constexpr Color impeller::Color::DeepSkyBlue ( )
inlinestaticconstexpr

Definition at line 428 of file color.h.

428  {
429  return {0.0f / 255.0f, 191.0f / 255.0f, 255.0f / 255.0f, 1.0f};
430  }

◆ DimGray()

static constexpr Color impeller::Color::DimGray ( )
inlinestaticconstexpr

Definition at line 432 of file color.h.

432  {
433  return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
434  }

◆ DimGrey()

static constexpr Color impeller::Color::DimGrey ( )
inlinestaticconstexpr

Definition at line 436 of file color.h.

436  {
437  return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
438  }

◆ DodgerBlue()

static constexpr Color impeller::Color::DodgerBlue ( )
inlinestaticconstexpr

Definition at line 440 of file color.h.

440  {
441  return {30.0f / 255.0f, 144.0f / 255.0f, 255.0f / 255.0f, 1.0f};
442  }

◆ Firebrick()

static constexpr Color impeller::Color::Firebrick ( )
inlinestaticconstexpr

Definition at line 444 of file color.h.

444  {
445  return {178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f};
446  }

◆ FloralWhite()

static constexpr Color impeller::Color::FloralWhite ( )
inlinestaticconstexpr

Definition at line 448 of file color.h.

448  {
449  return {255.0f / 255.0f, 250.0f / 255.0f, 240.0f / 255.0f, 1.0f};
450  }

◆ ForestGreen()

static constexpr Color impeller::Color::ForestGreen ( )
inlinestaticconstexpr

Definition at line 452 of file color.h.

452  {
453  return {34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f};
454  }

◆ Fuchsia()

static constexpr Color impeller::Color::Fuchsia ( )
inlinestaticconstexpr

Definition at line 456 of file color.h.

456  {
457  return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
458  }

Referenced by impeller::testing::TEST_P().

◆ Gainsboro()

static constexpr Color impeller::Color::Gainsboro ( )
inlinestaticconstexpr

Definition at line 460 of file color.h.

460  {
461  return {220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f, 1.0f};
462  }

◆ Ghostwhite()

static constexpr Color impeller::Color::Ghostwhite ( )
inlinestaticconstexpr

Definition at line 464 of file color.h.

464  {
465  return {248.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
466  }

◆ Gold()

static constexpr Color impeller::Color::Gold ( )
inlinestaticconstexpr

Definition at line 468 of file color.h.

468  {
469  return {255.0f / 255.0f, 215.0f / 255.0f, 0.0f / 255.0f, 1.0f};
470  }

◆ Goldenrod()

static constexpr Color impeller::Color::Goldenrod ( )
inlinestaticconstexpr

Definition at line 472 of file color.h.

472  {
473  return {218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f};
474  }

◆ Gray()

static constexpr Color impeller::Color::Gray ( )
inlinestaticconstexpr

Definition at line 476 of file color.h.

476  {
477  return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
478  }

◆ Green()

static constexpr Color impeller::Color::Green ( )
inlinestaticconstexpr

Definition at line 264 of file color.h.

264 { return {0.0f, 1.0f, 0.0f, 1.0f}; }

Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ GreenYellow()

static constexpr Color impeller::Color::GreenYellow ( )
inlinestaticconstexpr

Definition at line 480 of file color.h.

480  {
481  return {173.0f / 255.0f, 255.0f / 255.0f, 47.0f / 255.0f, 1.0f};
482  }

◆ Grey()

static constexpr Color impeller::Color::Grey ( )
inlinestaticconstexpr

Definition at line 484 of file color.h.

484  {
485  return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
486  }

◆ Honeydew()

static constexpr Color impeller::Color::Honeydew ( )
inlinestaticconstexpr

Definition at line 488 of file color.h.

488  {
489  return {240.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
490  }

◆ HotPink()

static constexpr Color impeller::Color::HotPink ( )
inlinestaticconstexpr

Definition at line 492 of file color.h.

492  {
493  return {255.0f / 255.0f, 105.0f / 255.0f, 180.0f / 255.0f, 1.0f};
494  }

◆ IndianRed()

static constexpr Color impeller::Color::IndianRed ( )
inlinestaticconstexpr

Definition at line 496 of file color.h.

496  {
497  return {205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f};
498  }

◆ Indigo()

static constexpr Color impeller::Color::Indigo ( )
inlinestaticconstexpr

Definition at line 500 of file color.h.

500  {
501  return {75.0f / 255.0f, 0.0f / 255.0f, 130.0f / 255.0f, 1.0f};
502  }

◆ IsOpaque()

constexpr bool impeller::Color::IsOpaque ( ) const
inlineconstexpr

Definition at line 880 of file color.h.

880 { return alpha == 1.0f; }

References alpha.

Referenced by impeller::SolidColorContents::IsOpaque().

◆ IsTransparent()

constexpr bool impeller::Color::IsTransparent ( ) const
inlineconstexpr

Definition at line 878 of file color.h.

878 { return alpha == 0.0f; }

References alpha.

◆ Ivory()

static constexpr Color impeller::Color::Ivory ( )
inlinestaticconstexpr

Definition at line 504 of file color.h.

504  {
505  return {255.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
506  }

◆ Khaki()

static constexpr Color impeller::Color::Khaki ( )
inlinestaticconstexpr

Definition at line 508 of file color.h.

508  {
509  return {240.0f / 255.0f, 230.0f / 255.0f, 140.0f / 255.0f, 1.0f};
510  }

◆ Lavender()

static constexpr Color impeller::Color::Lavender ( )
inlinestaticconstexpr

Definition at line 512 of file color.h.

512  {
513  return {230.0f / 255.0f, 230.0f / 255.0f, 250.0f / 255.0f, 1.0f};
514  }

◆ LavenderBlush()

static constexpr Color impeller::Color::LavenderBlush ( )
inlinestaticconstexpr

Definition at line 516 of file color.h.

516  {
517  return {255.0f / 255.0f, 240.0f / 255.0f, 245.0f / 255.0f, 1.0f};
518  }

◆ LawnGreen()

static constexpr Color impeller::Color::LawnGreen ( )
inlinestaticconstexpr

Definition at line 520 of file color.h.

520  {
521  return {124.0f / 255.0f, 252.0f / 255.0f, 0.0f / 255.0f, 1.0f};
522  }

◆ LemonChiffon()

static constexpr Color impeller::Color::LemonChiffon ( )
inlinestaticconstexpr

Definition at line 524 of file color.h.

524  {
525  return {255.0f / 255.0f, 250.0f / 255.0f, 205.0f / 255.0f, 1.0f};
526  }

◆ Lerp()

constexpr static Color impeller::Color::Lerp ( Color  a,
Color  b,
Scalar  t 
)
inlinestaticconstexpr

Return a color that is linearly interpolated between colors a and b, according to the value of t.

Parameters
aThe lower color.
bThe upper color.
tA value between 0.0f and 1.0f, inclusive.
Returns
constexpr Color

Definition at line 232 of file color.h.

232  {
233  return a + (b - a) * t;
234  }

Referenced by impeller::CreateGradientBuffer(), impeller::DoColorBlend(), impeller::DoColorBlendComponents(), and impeller::testing::TEST().

◆ LightBlue()

static constexpr Color impeller::Color::LightBlue ( )
inlinestaticconstexpr

Definition at line 528 of file color.h.

528  {
529  return {173.0f / 255.0f, 216.0f / 255.0f, 230.0f / 255.0f, 1.0f};
530  }

◆ LightCoral()

static constexpr Color impeller::Color::LightCoral ( )
inlinestaticconstexpr

Definition at line 532 of file color.h.

532  {
533  return {240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
534  }

◆ LightCyan()

static constexpr Color impeller::Color::LightCyan ( )
inlinestaticconstexpr

Definition at line 536 of file color.h.

536  {
537  return {224.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
538  }

◆ LightGoldenrodYellow()

static constexpr Color impeller::Color::LightGoldenrodYellow ( )
inlinestaticconstexpr

Definition at line 540 of file color.h.

540  {
541  return {50.0f / 255.0f, 250.0f / 255.0f, 210.0f / 255.0f, 1.0f};
542  }

◆ LightGray()

static constexpr Color impeller::Color::LightGray ( )
inlinestaticconstexpr

Definition at line 544 of file color.h.

544  {
545  return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
546  }

◆ LightGreen()

static constexpr Color impeller::Color::LightGreen ( )
inlinestaticconstexpr

Definition at line 548 of file color.h.

548  {
549  return {144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f};
550  }

◆ LightGrey()

static constexpr Color impeller::Color::LightGrey ( )
inlinestaticconstexpr

Definition at line 552 of file color.h.

552  {
553  return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
554  }

◆ LightPink()

static constexpr Color impeller::Color::LightPink ( )
inlinestaticconstexpr

Definition at line 556 of file color.h.

556  {
557  return {255.0f / 255.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f};
558  }

◆ LightSalmon()

static constexpr Color impeller::Color::LightSalmon ( )
inlinestaticconstexpr

Definition at line 560 of file color.h.

560  {
561  return {255.0f / 255.0f, 160.0f / 255.0f, 122.0f / 255.0f, 1.0f};
562  }

◆ LightSeaGreen()

static constexpr Color impeller::Color::LightSeaGreen ( )
inlinestaticconstexpr

Definition at line 564 of file color.h.

564  {
565  return {32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f};
566  }

◆ LightSkyBlue()

static constexpr Color impeller::Color::LightSkyBlue ( )
inlinestaticconstexpr

Definition at line 568 of file color.h.

568  {
569  return {135.0f / 255.0f, 206.0f / 255.0f, 250.0f / 255.0f, 1.0f};
570  }

◆ LightSlateGray()

static constexpr Color impeller::Color::LightSlateGray ( )
inlinestaticconstexpr

Definition at line 572 of file color.h.

572  {
573  return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
574  }

◆ LightSlateGrey()

static constexpr Color impeller::Color::LightSlateGrey ( )
inlinestaticconstexpr

Definition at line 576 of file color.h.

576  {
577  return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
578  }

◆ LightSteelBlue()

static constexpr Color impeller::Color::LightSteelBlue ( )
inlinestaticconstexpr

Definition at line 580 of file color.h.

580  {
581  return {176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f};
582  }

◆ LightYellow()

static constexpr Color impeller::Color::LightYellow ( )
inlinestaticconstexpr

Definition at line 584 of file color.h.

584  {
585  return {255.0f / 255.0f, 255.0f / 255.0f, 224.0f / 255.0f, 1.0f};
586  }

◆ Lime()

static constexpr Color impeller::Color::Lime ( )
inlinestaticconstexpr

Definition at line 588 of file color.h.

588  {
589  return {0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
590  }

◆ LimeGreen()

static constexpr Color impeller::Color::LimeGreen ( )
inlinestaticconstexpr

Definition at line 592 of file color.h.

592  {
593  return {50.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
594  }

◆ LinearToSRGB()

Color impeller::Color::LinearToSRGB ( ) const

Convert the color from linear space to sRGB space.

   The color is assumed to be unpremultiplied. If the color is
   premultipled, the conversion output will be incorrect. 

Definition at line 376 of file color.cc.

376  {
377  static auto conversion = [](Scalar component) {
378  if (component <= 0.0031308) {
379  return component * 12.92;
380  }
381  return 1.055 * pow(component, (1.0 / 2.4)) - 0.055;
382  };
383 
384  return Color(conversion(red), conversion(green), conversion(blue), alpha);
385 }

References alpha, blue, Color(), green, and red.

Referenced by impeller::testing::TEST().

◆ Linen()

static constexpr Color impeller::Color::Linen ( )
inlinestaticconstexpr

Definition at line 596 of file color.h.

596  {
597  return {250.0f / 255.0f, 240.0f / 255.0f, 230.0f / 255.0f, 1.0f};
598  }

◆ Magenta()

static constexpr Color impeller::Color::Magenta ( )
inlinestaticconstexpr

Definition at line 600 of file color.h.

600  {
601  return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
602  }

◆ MakeRGBA8()

static constexpr Color impeller::Color::MakeRGBA8 ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a 
)
inlinestaticconstexpr

Definition at line 152 of file color.h.

152  {
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  }

References Color().

Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ Maroon()

static constexpr Color impeller::Color::Maroon ( )
inlinestaticconstexpr

Definition at line 604 of file color.h.

604  {
605  return {128.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
606  }

Referenced by impeller::testing::TEST_P().

◆ MediumAquamarine()

static constexpr Color impeller::Color::MediumAquamarine ( )
inlinestaticconstexpr

Definition at line 608 of file color.h.

608  {
609  return {102.0f / 255.0f, 205.0f / 255.0f, 170.0f / 255.0f, 1.0f};
610  }

◆ MediumBlue()

static constexpr Color impeller::Color::MediumBlue ( )
inlinestaticconstexpr

Definition at line 612 of file color.h.

612  {
613  return {0.0f / 255.0f, 0.0f / 255.0f, 205.0f / 255.0f, 1.0f};
614  }

◆ MediumOrchid()

static constexpr Color impeller::Color::MediumOrchid ( )
inlinestaticconstexpr

Definition at line 616 of file color.h.

616  {
617  return {186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f};
618  }

◆ MediumPurple()

static constexpr Color impeller::Color::MediumPurple ( )
inlinestaticconstexpr

Definition at line 620 of file color.h.

620  {
621  return {147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f};
622  }

◆ MediumSeagreen()

static constexpr Color impeller::Color::MediumSeagreen ( )
inlinestaticconstexpr

Definition at line 624 of file color.h.

624  {
625  return {60.0f / 255.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f};
626  }

◆ MediumSlateBlue()

static constexpr Color impeller::Color::MediumSlateBlue ( )
inlinestaticconstexpr

Definition at line 628 of file color.h.

628  {
629  return {123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f};
630  }

◆ MediumSpringGreen()

static constexpr Color impeller::Color::MediumSpringGreen ( )
inlinestaticconstexpr

Definition at line 632 of file color.h.

632  {
633  return {0.0f / 255.0f, 250.0f / 255.0f, 154.0f / 255.0f, 1.0f};
634  }

◆ MediumTurquoise()

static constexpr Color impeller::Color::MediumTurquoise ( )
inlinestaticconstexpr

Definition at line 636 of file color.h.

636  {
637  return {72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f};
638  }

◆ MediumVioletRed()

static constexpr Color impeller::Color::MediumVioletRed ( )
inlinestaticconstexpr

Definition at line 640 of file color.h.

640  {
641  return {199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f};
642  }

◆ MidnightBlue()

static constexpr Color impeller::Color::MidnightBlue ( )
inlinestaticconstexpr

Definition at line 644 of file color.h.

644  {
645  return {25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f};
646  }

◆ MintCream()

static constexpr Color impeller::Color::MintCream ( )
inlinestaticconstexpr

Definition at line 648 of file color.h.

648  {
649  return {245.0f / 255.0f, 255.0f / 255.0f, 250.0f / 255.0f, 1.0f};
650  }

Referenced by impeller::testing::TEST_P().

◆ MistyRose()

static constexpr Color impeller::Color::MistyRose ( )
inlinestaticconstexpr

Definition at line 652 of file color.h.

652  {
653  return {255.0f / 255.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f};
654  }

◆ Moccasin()

static constexpr Color impeller::Color::Moccasin ( )
inlinestaticconstexpr

Definition at line 656 of file color.h.

656  {
657  return {255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f};
658  }

◆ NavajoWhite()

static constexpr Color impeller::Color::NavajoWhite ( )
inlinestaticconstexpr

Definition at line 660 of file color.h.

660  {
661  return {255.0f / 255.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f};
662  }

◆ Navy()

static constexpr Color impeller::Color::Navy ( )
inlinestaticconstexpr

Definition at line 664 of file color.h.

664  {
665  return {0.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
666  }

◆ OldLace()

static constexpr Color impeller::Color::OldLace ( )
inlinestaticconstexpr

Definition at line 668 of file color.h.

668  {
669  return {253.0f / 255.0f, 245.0f / 255.0f, 230.0f / 255.0f, 1.0f};
670  }

◆ Olive()

static constexpr Color impeller::Color::Olive ( )
inlinestaticconstexpr

Definition at line 672 of file color.h.

672  {
673  return {128.0f / 255.0f, 128.0f / 255.0f, 0.0f / 255.0f, 1.0f};
674  }

◆ OliveDrab()

static constexpr Color impeller::Color::OliveDrab ( )
inlinestaticconstexpr

Definition at line 676 of file color.h.

676  {
677  return {107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f};
678  }

◆ operator*() [1/2]

constexpr Color impeller::Color::operator* ( const Color c) const
inlineconstexpr

Definition at line 192 of file color.h.

192  {
193  return {red * c.red, green * c.green, blue * c.blue, alpha * c.alpha};
194  }

References alpha, blue, green, and red.

◆ operator*() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator* ( value) const
inlineconstexpr

Definition at line 197 of file color.h.

197  {
198  auto v = static_cast<Scalar>(value);
199  return {red * v, green * v, blue * v, alpha * v};
200  }

References alpha, blue, green, and red.

◆ operator+() [1/2]

constexpr Color impeller::Color::operator+ ( const Color c) const
inlineconstexpr

Definition at line 172 of file color.h.

172  {
173  return {red + c.red, green + c.green, blue + c.blue, alpha + c.alpha};
174  }

References alpha, blue, green, and red.

◆ operator+() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator+ ( value) const
inlineconstexpr

Definition at line 177 of file color.h.

177  {
178  auto v = static_cast<Scalar>(value);
179  return {red + v, green + v, blue + v, alpha + v};
180  }

References alpha, blue, green, and red.

◆ operator-() [1/2]

constexpr Color impeller::Color::operator- ( const Color c) const
inlineconstexpr

Definition at line 182 of file color.h.

182  {
183  return {red - c.red, green - c.green, blue - c.blue, alpha - c.alpha};
184  }

References alpha, blue, green, and red.

◆ operator-() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator- ( value) const
inlineconstexpr

Definition at line 187 of file color.h.

187  {
188  auto v = static_cast<Scalar>(value);
189  return {red - v, green - v, blue - v, alpha - v};
190  }

References alpha, blue, green, and red.

◆ operator/() [1/2]

constexpr Color impeller::Color::operator/ ( const Color c) const
inlineconstexpr

Definition at line 202 of file color.h.

202  {
203  return {red * c.red, green * c.green, blue * c.blue, alpha * c.alpha};
204  }

References alpha, blue, green, and red.

◆ operator/() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator/ ( value) const
inlineconstexpr

Definition at line 207 of file color.h.

207  {
208  auto v = static_cast<Scalar>(value);
209  return {red / v, green / v, blue / v, alpha / v};
210  }

References alpha, blue, green, and red.

◆ operator==()

constexpr bool impeller::Color::operator== ( const Color c) const
inlineconstexpr

Definition at line 167 of file color.h.

167  {
168  return ScalarNearlyEqual(red, c.red) && ScalarNearlyEqual(green, c.green) &&
169  ScalarNearlyEqual(blue, c.blue) && ScalarNearlyEqual(alpha, c.alpha);
170  }

References alpha, blue, green, red, and impeller::ScalarNearlyEqual().

◆ Orange()

static constexpr Color impeller::Color::Orange ( )
inlinestaticconstexpr

Definition at line 680 of file color.h.

680  {
681  return {255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f};
682  }

◆ OrangeRed()

static constexpr Color impeller::Color::OrangeRed ( )
inlinestaticconstexpr

Definition at line 684 of file color.h.

684  {
685  return {255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f};
686  }

◆ Orchid()

static constexpr Color impeller::Color::Orchid ( )
inlinestaticconstexpr

Definition at line 688 of file color.h.

688  {
689  return {218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f};
690  }

◆ PaleGoldenrod()

static constexpr Color impeller::Color::PaleGoldenrod ( )
inlinestaticconstexpr

Definition at line 692 of file color.h.

692  {
693  return {238.0f / 255.0f, 232.0f / 255.0f, 170.0f / 255.0f, 1.0f};
694  }

◆ PaleGreen()

static constexpr Color impeller::Color::PaleGreen ( )
inlinestaticconstexpr

Definition at line 696 of file color.h.

696  {
697  return {152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f};
698  }

◆ PaleTurquoise()

static constexpr Color impeller::Color::PaleTurquoise ( )
inlinestaticconstexpr

Definition at line 700 of file color.h.

700  {
701  return {175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f};
702  }

◆ PaleVioletRed()

static constexpr Color impeller::Color::PaleVioletRed ( )
inlinestaticconstexpr

Definition at line 704 of file color.h.

704  {
705  return {219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f};
706  }

◆ PapayaWhip()

static constexpr Color impeller::Color::PapayaWhip ( )
inlinestaticconstexpr

Definition at line 708 of file color.h.

708  {
709  return {255.0f / 255.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f};
710  }

◆ Peachpuff()

static constexpr Color impeller::Color::Peachpuff ( )
inlinestaticconstexpr

Definition at line 712 of file color.h.

712  {
713  return {255.0f / 255.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f};
714  }

◆ Peru()

static constexpr Color impeller::Color::Peru ( )
inlinestaticconstexpr

Definition at line 716 of file color.h.

716  {
717  return {205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f};
718  }

◆ Pink()

static constexpr Color impeller::Color::Pink ( )
inlinestaticconstexpr

Definition at line 720 of file color.h.

720  {
721  return {255.0f / 255.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f};
722  }

◆ Plum()

static constexpr Color impeller::Color::Plum ( )
inlinestaticconstexpr

Definition at line 724 of file color.h.

724  {
725  return {221.0f / 255.0f, 160.0f / 255.0f, 221.0f / 255.0f, 1.0f};
726  }

◆ PowderBlue()

static constexpr Color impeller::Color::PowderBlue ( )
inlinestaticconstexpr

Definition at line 728 of file color.h.

728  {
729  return {176.0f / 255.0f, 224.0f / 255.0f, 230.0f / 255.0f, 1.0f};
730  }

◆ Premultiply()

constexpr Color impeller::Color::Premultiply ( ) const
inlineconstexpr

◆ Purple()

static constexpr Color impeller::Color::Purple ( )
inlinestaticconstexpr

Definition at line 732 of file color.h.

732  {
733  return {128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
734  }

◆ Random()

static Color impeller::Color::Random ( )
inlinestatic

Definition at line 840 of file color.h.

840  {
841  return {
842  static_cast<Scalar>((std::rand() % 255) / 255.0f), //
843  static_cast<Scalar>((std::rand() % 255) / 255.0f), //
844  static_cast<Scalar>((std::rand() % 255) / 255.0f), //
845  1.0f //
846  };
847  }

Referenced by impeller::testing::TEST_P().

◆ Red()

static constexpr Color impeller::Color::Red ( )
inlinestaticconstexpr

Definition at line 262 of file color.h.

262 { return {1.0f, 0.0f, 0.0f, 1.0f}; }

Referenced by impeller::testing::CreatePassWithRectPath(), impeller::testing::TEST(), impeller::scene::testing::TEST_P(), and impeller::testing::TEST_P().

◆ RosyBrown()

static constexpr Color impeller::Color::RosyBrown ( )
inlinestaticconstexpr

Definition at line 736 of file color.h.

736  {
737  return {188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f};
738  }

◆ RoyalBlue()

static constexpr Color impeller::Color::RoyalBlue ( )
inlinestaticconstexpr

Definition at line 740 of file color.h.

740  {
741  return {65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f};
742  }

◆ SaddleBrown()

static constexpr Color impeller::Color::SaddleBrown ( )
inlinestaticconstexpr

Definition at line 744 of file color.h.

744  {
745  return {139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f};
746  }

◆ Salmon()

static constexpr Color impeller::Color::Salmon ( )
inlinestaticconstexpr

Definition at line 748 of file color.h.

748  {
749  return {250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f};
750  }

◆ SandyBrown()

static constexpr Color impeller::Color::SandyBrown ( )
inlinestaticconstexpr

Definition at line 752 of file color.h.

752  {
753  return {244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f};
754  }

◆ Seagreen()

static constexpr Color impeller::Color::Seagreen ( )
inlinestaticconstexpr

Definition at line 756 of file color.h.

756  {
757  return {46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f};
758  }

◆ Seashell()

static constexpr Color impeller::Color::Seashell ( )
inlinestaticconstexpr

Definition at line 760 of file color.h.

760  {
761  return {255.0f / 255.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f};
762  }

◆ Sienna()

static constexpr Color impeller::Color::Sienna ( )
inlinestaticconstexpr

Definition at line 764 of file color.h.

764  {
765  return {160.0f / 255.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f};
766  }

◆ Silver()

static constexpr Color impeller::Color::Silver ( )
inlinestaticconstexpr

Definition at line 768 of file color.h.

768  {
769  return {192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f};
770  }

◆ SkyBlue()

static constexpr Color impeller::Color::SkyBlue ( )
inlinestaticconstexpr

Definition at line 772 of file color.h.

772  {
773  return {135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f};
774  }

Referenced by impeller::testing::TEST_P().

◆ SlateBlue()

static constexpr Color impeller::Color::SlateBlue ( )
inlinestaticconstexpr

Definition at line 776 of file color.h.

776  {
777  return {106.0f / 255.0f, 90.0f / 255.0f, 205.0f / 255.0f, 1.0f};
778  }

◆ SlateGray()

static constexpr Color impeller::Color::SlateGray ( )
inlinestaticconstexpr

Definition at line 780 of file color.h.

780  {
781  return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
782  }

◆ SlateGrey()

static constexpr Color impeller::Color::SlateGrey ( )
inlinestaticconstexpr

Definition at line 784 of file color.h.

784  {
785  return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
786  }

◆ Snow()

static constexpr Color impeller::Color::Snow ( )
inlinestaticconstexpr

Definition at line 788 of file color.h.

788  {
789  return {255.0f / 255.0f, 250.0f / 255.0f, 250.0f / 255.0f, 1.0f};
790  }

◆ SpringGreen()

static constexpr Color impeller::Color::SpringGreen ( )
inlinestaticconstexpr

Definition at line 792 of file color.h.

792  {
793  return {0.0f / 255.0f, 255.0f / 255.0f, 127.0f / 255.0f, 1.0f};
794  }

◆ SRGBToLinear()

Color impeller::Color::SRGBToLinear ( ) const

Convert the color from sRGB space to linear space.

   The color is assumed to be unpremultiplied. If the color is
   premultipled, the conversion output will be incorrect. 

Definition at line 387 of file color.cc.

387  {
388  static auto conversion = [](Scalar component) {
389  if (component <= 0.04045) {
390  return component / 12.92;
391  }
392  return pow((component + 0.055) / 1.055, 2.4);
393  };
394 
395  return Color(conversion(red), conversion(green), conversion(blue), alpha);
396 }

References alpha, blue, Color(), green, and red.

Referenced by impeller::testing::TEST().

◆ SteelBlue()

static constexpr Color impeller::Color::SteelBlue ( )
inlinestaticconstexpr

Definition at line 796 of file color.h.

796  {
797  return {70.0f / 255.0f, 130.0f / 255.0f, 180.0f / 255.0f, 1.0f};
798  }

◆ Tan()

static constexpr Color impeller::Color::Tan ( )
inlinestaticconstexpr

Definition at line 800 of file color.h.

800  {
801  return {210.0f / 255.0f, 180.0f / 255.0f, 140.0f / 255.0f, 1.0f};
802  }

◆ Teal()

static constexpr Color impeller::Color::Teal ( )
inlinestaticconstexpr

Definition at line 804 of file color.h.

804  {
805  return {0.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
806  }

◆ Thistle()

static constexpr Color impeller::Color::Thistle ( )
inlinestaticconstexpr

Definition at line 808 of file color.h.

808  {
809  return {216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f};
810  }

◆ ToIColor()

static constexpr uint32_t impeller::Color::ToIColor ( Color  color)
inlinestaticconstexpr

Convert this color to a 32-bit representation.

Definition at line 159 of file color.h.

159  {
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  }

References alpha, blue, green, and red.

Referenced by impeller::AtlasContents::GenerateSubAtlas(), impeller::testing::TEST(), and impeller::testing::toColor().

◆ Tomato()

static constexpr Color impeller::Color::Tomato ( )
inlinestaticconstexpr

Definition at line 812 of file color.h.

812  {
813  return {255.0f / 255.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f};
814  }

◆ ToR8G8B8A8()

constexpr std::array<uint8_t, 4> impeller::Color::ToR8G8B8A8 ( ) const
inlineconstexpr

Convert to R8G8B8A8 representation.

Returns
constexpr std::array<u_int8, 4>

Definition at line 246 of file color.h.

246  {
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  }

References alpha, blue, green, and red.

Referenced by impeller::AppendColor(), and impeller::testing::TEST().

◆ Turquoise()

static constexpr Color impeller::Color::Turquoise ( )
inlinestaticconstexpr

Definition at line 816 of file color.h.

816  {
817  return {64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f};
818  }

◆ Unpremultiply()

constexpr Color impeller::Color::Unpremultiply ( ) const
inlineconstexpr

Definition at line 216 of file color.h.

216  {
217  if (ScalarNearlyEqual(alpha, 0.0f)) {
218  return Color::BlackTransparent();
219  }
220  return {red / alpha, green / alpha, blue / alpha, alpha};
221  }

References alpha, BlackTransparent(), blue, green, red, and impeller::ScalarNearlyEqual().

Referenced by impeller::DoColorBlend(), impeller::DoColorBlendComponents(), and impeller::testing::TEST().

◆ Violet()

static constexpr Color impeller::Color::Violet ( )
inlinestaticconstexpr

Definition at line 820 of file color.h.

820  {
821  return {238.0f / 255.0f, 130.0f / 255.0f, 238.0f / 255.0f, 1.0f};
822  }

◆ Wheat()

static constexpr Color impeller::Color::Wheat ( )
inlinestaticconstexpr

Definition at line 824 of file color.h.

824  {
825  return {245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f};
826  }

◆ White()

◆ Whitesmoke()

static constexpr Color impeller::Color::Whitesmoke ( )
inlinestaticconstexpr

Definition at line 828 of file color.h.

828  {
829  return {245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f};
830  }

◆ WhiteTransparent()

static constexpr Color impeller::Color::WhiteTransparent ( )
inlinestaticconstexpr

Definition at line 258 of file color.h.

258 { return {1.0f, 1.0f, 1.0f, 0.0f}; }

Referenced by impeller::testing::TEST_P().

◆ WithAlpha()

constexpr Color impeller::Color::WithAlpha ( Scalar  new_alpha) const
inlineconstexpr

◆ Yellow()

static constexpr Color impeller::Color::Yellow ( )
inlinestaticconstexpr

Definition at line 832 of file color.h.

832  {
833  return {255.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
834  }

Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ YellowGreen()

static constexpr Color impeller::Color::YellowGreen ( )
inlinestaticconstexpr

Definition at line 836 of file color.h.

836  {
837  return {154.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
838  }

Member Data Documentation

◆ alpha

◆ blue

◆ green

◆ red


The documentation for this struct was generated from the following files:
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::BlendMode::kMultiply
@ kMultiply
impeller::Color::Color
constexpr Color()
Definition: color.h:143
impeller::ComponentChoose
static constexpr Vector3 ComponentChoose(Vector3 a, Vector3 b, Vector3 value, Scalar cutoff)
Definition: color.cc:178
impeller::kEhCloseEnough
constexpr float kEhCloseEnough
Definition: constants.h:55
impeller::BlendMode::kSourceIn
@ kSourceIn
impeller::Color::alpha
Scalar alpha
Definition: color.h:141
impeller::BlendMode::kSaturation
@ kSaturation
impeller::BlendMode::kHue
@ kHue
impeller::BlendMode::kDestinationIn
@ kDestinationIn
impeller::BlendMode::kDarken
@ kDarken
impeller::BlendMode::kColor
@ kColor
impeller::Color::green
Scalar green
Definition: color.h:131
impeller::Min
static constexpr Color Min(Color c, float threshold)
Definition: color.cc:132
impeller::BlendMode::kLuminosity
@ kLuminosity
impeller::BlendMode::kXor
@ kXor
impeller::BlendMode::kOverlay
@ kOverlay
impeller::BlendMode::kColorBurn
@ kColorBurn
impeller::BlendMode::kLighten
@ kLighten
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::BlendMode::kHardLight
@ kHardLight
impeller::BlendMode::kPlus
@ kPlus
impeller::BlendMode::kDestination
@ kDestination
impeller::SetSaturation
static constexpr Vector3 SetSaturation(Vector3 color, Scalar saturation)
Definition: color.cc:171
impeller::SetLuminosity
static constexpr Vector3 SetLuminosity(Vector3 color, Scalar luminosity)
Definition: color.cc:160
impeller::Color::red
Scalar red
Definition: color.h:126
impeller::BlendMode::kDestinationATop
@ kDestinationATop
impeller::DoColorBlendComponents
static constexpr Color DoColorBlendComponents(Color d, Color s, const std::function< Scalar(Scalar, Scalar)> &blend_func)
Definition: color.cc:207
impeller::Luminosity
static constexpr Scalar Luminosity(Vector3 color)
Definition: color.cc:140
impeller::BlendMode::kDestinationOut
@ kDestinationOut
impeller::BlendMode::kSoftLight
@ kSoftLight
impeller::DoColorBlend
static constexpr Color DoColorBlend(Color d, Color s, const std::function< Vector3(Vector3, Vector3)> &blend_rgb_func)
Definition: color.cc:196
impeller::BlendMode::kDifference
@ kDifference
impeller::BlendMode::kExclusion
@ kExclusion
impeller::BlendMode::kDestinationOver
@ kDestinationOver
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:260
impeller::BlendMode::kClear
@ kClear
impeller::ScalarNearlyEqual
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
Definition: scalar.h:27
impeller::BlendMode::kColorDodge
@ kColorDodge
impeller::BlendMode::kSourceATop
@ kSourceATop
impeller::BlendMode::kModulate
@ kModulate
impeller::Color::blue
Scalar blue
Definition: color.h:136
impeller::BlendMode::kScreen
@ kScreen
impeller::BlendMode::kSourceOut
@ kSourceOut
impeller::BlendMode::kSource
@ kSource
impeller::Saturation
static constexpr Scalar Saturation(Vector3 color)
Definition: color.cc:166