Flutter Impeller
impeller::Color Struct Reference

#include <color.h>

Public Member Functions

constexpr Color ()
 
 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
 
std::array< uint8_t, 4 > ToR8G8B8A8 () const
 Convert to R8G8B8A8 representation. More...
 
uint32_t ToARGB () const
 Convert to ARGB 32 bit color. 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 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
 

Friends

template<typename H >
H AbslHashValue (H h, const Color &c)
 

Detailed Description

Represents a RGBA color

Definition at line 124 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/3]

constexpr impeller::Color::Color ( )
inlineconstexpr

Definition at line 145 of file color.h.

145 {}

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

◆ Color() [2/3]

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

Definition at line 50 of file color.cc.

51  : red(value.x), green(value.y), blue(value.z), alpha(value.w) {}
int32_t value
Scalar blue
Definition: color.h:138
Scalar alpha
Definition: color.h:143
Scalar red
Definition: color.h:128
Scalar green
Definition: color.h:133

◆ Color() [3/3]

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 287 of file color.h.

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

◆ AntiqueWhite()

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

Definition at line 291 of file color.h.

291  {
292  return {250.0f / 255.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f};
293  }

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

◆ 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 299 of file color.cc.

299  {
300  auto* c = color_matrix.array;
301  return Color(
302  c[0] * red + c[1] * green + c[2] * blue + c[3] * alpha + c[4],
303  c[5] * red + c[6] * green + c[7] * blue + c[8] * alpha + c[9],
304  c[10] * red + c[11] * green + c[12] * blue + c[13] * alpha + c[14],
305  c[15] * red + c[16] * green + c[17] * blue + c[18] * alpha + c[19])
306  .Clamp01();
307 }
constexpr Color()
Definition: color.h:145

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

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

◆ Aqua()

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

Definition at line 295 of file color.h.

295  {
296  return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
297  }

◆ AquaMarine()

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

Definition at line 299 of file color.h.

299  {
300  return {127.0f / 255.0f, 255.0f / 255.0f, 212.0f / 255.0f, 1.0f};
301  }

◆ Azure()

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

Definition at line 303 of file color.h.

303  {
304  return {240.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
305  }

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

◆ Beige()

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

Definition at line 307 of file color.h.

307  {
308  return {245.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f, 1.0f};
309  }

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

◆ Bisque()

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

Definition at line 311 of file color.h.

311  {
312  return {255.0f / 255.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f};
313  }

◆ Black()

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

Definition at line 271 of file color.h.

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

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

◆ BlackTransparent()

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

◆ BlanchedAlmond()

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

Definition at line 315 of file color.h.

315  {
316  return {255.0f / 255.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f};
317  }

◆ 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 155 of file color.cc.

155  {
156  Color dst = *this;
157 
158  switch (blend_mode) {
159  case BlendMode::kClear:
160  return Color::BlackTransparent();
161  case BlendMode::kSrc:
162  return src;
163  case BlendMode::kDst:
164  return dst;
165  case BlendMode::kSrcOver:
166  // r = s + (1-sa)*d
167  return (src.Premultiply() + dst.Premultiply() * (1 - src.alpha))
168  .Unpremultiply();
169  case BlendMode::kDstOver:
170  // r = d + (1-da)*s
171  return (dst.Premultiply() + src.Premultiply() * (1 - dst.alpha))
172  .Unpremultiply();
173  case BlendMode::kSrcIn:
174  // r = s * da
175  return (src.Premultiply() * dst.alpha).Unpremultiply();
176  case BlendMode::kDstIn:
177  // r = d * sa
178  return (dst.Premultiply() * src.alpha).Unpremultiply();
179  case BlendMode::kSrcOut:
180  // r = s * ( 1- da)
181  return (src.Premultiply() * (1 - dst.alpha)).Unpremultiply();
182  case BlendMode::kDstOut:
183  // r = d * (1-sa)
184  return (dst.Premultiply() * (1 - src.alpha)).Unpremultiply();
185  case BlendMode::kSrcATop:
186  // r = s*da + d*(1-sa)
187  return (src.Premultiply() * dst.alpha +
188  dst.Premultiply() * (1 - src.alpha))
189  .Unpremultiply();
190  case BlendMode::kDstATop:
191  // r = d*sa + s*(1-da)
192  return (dst.Premultiply() * src.alpha +
193  src.Premultiply() * (1 - dst.alpha))
194  .Unpremultiply();
195  case BlendMode::kXor:
196  // r = s*(1-da) + d*(1-sa)
197  return (src.Premultiply() * (1 - dst.alpha) +
198  dst.Premultiply() * (1 - src.alpha))
199  .Unpremultiply();
200  case BlendMode::kPlus:
201  // r = min(s + d, 1)
202  return (Min(src.Premultiply() + dst.Premultiply(), 1)).Unpremultiply();
204  // r = s*d
205  return (src.Premultiply() * dst.Premultiply()).Unpremultiply();
206  case BlendMode::kScreen: {
207  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
208  return s + d - s * d;
209  });
210  }
211  case BlendMode::kOverlay:
212  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
213  // The same as HardLight, but with the source and destination reversed.
214  Vector3 screen_src = 2.0 * d - 1.0;
215  Vector3 screen = screen_src + s - screen_src * s;
216  return ComponentChoose(s * (2.0 * d), //
217  screen, //
218  d, //
219  0.5);
220  });
221  case BlendMode::kDarken:
222  return DoColorBlend(
223  dst, src, [](Vector3 d, Vector3 s) -> Vector3 { return d.Min(s); });
224  case BlendMode::kLighten:
225  return DoColorBlend(
226  dst, src, [](Vector3 d, Vector3 s) -> Vector3 { return d.Max(s); });
228  return DoColorBlendComponents(dst, src, [](Scalar d, Scalar s) -> Scalar {
229  if (d < kEhCloseEnough) {
230  return 0.0f;
231  }
232  if (1.0 - s < kEhCloseEnough) {
233  return 1.0f;
234  }
235  return std::min(1.0f, d / (1.0f - s));
236  });
238  return DoColorBlendComponents(dst, src, [](Scalar d, Scalar s) -> Scalar {
239  if (1.0 - d < kEhCloseEnough) {
240  return 1.0f;
241  }
242  if (s < kEhCloseEnough) {
243  return 0.0f;
244  }
245  return 1.0f - std::min(1.0f, (1.0f - d) / s);
246  });
248  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
249  Vector3 screen_src = 2.0 * s - 1.0;
250  Vector3 screen = screen_src + d - screen_src * d;
251  return ComponentChoose(d * (2.0 * s), //
252  screen, //
253  s, //
254  0.5);
255  });
257  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
258  Vector3 D = ComponentChoose(((16.0 * d - 12.0) * d + 4.0) * d, //
259  Vector3(std::sqrt(d.x), std::sqrt(d.y),
260  std::sqrt(d.z)), //
261  d, //
262  0.25);
263  return ComponentChoose(d - (1.0 - 2.0 * s) * d * (1.0 - d), //
264  d + (2.0 * s - 1.0) * (D - d), //
265  s, //
266  0.5);
267  });
269  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
270  return (d - s).Abs();
271  });
273  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
274  return d + s - 2.0f * d * s;
275  });
277  return DoColorBlend(
278  dst, src, [](Vector3 d, Vector3 s) -> Vector3 { return d * s; });
279  case BlendMode::kHue: {
280  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
282  });
283  }
285  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
287  });
288  case BlendMode::kColor:
289  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
290  return SetLuminosity(s, Luminosity(d));
291  });
293  return DoColorBlend(dst, src, [](Vector3 d, Vector3 s) -> Vector3 {
294  return SetLuminosity(d, Luminosity(s));
295  });
296  }
297 }
static constexpr Color Min(Color c, float threshold)
Definition: color.cc:53
static constexpr Vector3 SetSaturation(Vector3 color, Scalar saturation)
Definition: color.cc:92
float Scalar
Definition: scalar.h:19
static Color DoColorBlendComponents(Color dst, Color src, const std::function< Scalar(Scalar, Scalar)> &blend_func)
Definition: color.cc:145
constexpr float kEhCloseEnough
Definition: constants.h:57
static constexpr Scalar Saturation(Vector3 color)
Definition: color.cc:87
static constexpr Vector3 SetLuminosity(Vector3 color, Scalar luminosity)
Definition: color.cc:81
static Color DoColorBlend(Color dst, Color src, const std::function< Vector3(Vector3, Vector3)> &blend_rgb_func)
Definition: color.cc:137
static constexpr Vector3 ComponentChoose(Vector3 a, Vector3 b, Vector3 value, Scalar cutoff)
Definition: color.cc:99
static constexpr Scalar Luminosity(Vector3 color)
Definition: color.cc:61
static constexpr Color BlackTransparent()
Definition: color.h:275

References alpha, BlackTransparent(), impeller::ComponentChoose(), impeller::DoColorBlend(), impeller::DoColorBlendComponents(), impeller::kClear, impeller::kColor, impeller::kColorBurn, impeller::kColorDodge, impeller::kDarken, impeller::kDifference, impeller::kDst, impeller::kDstATop, impeller::kDstIn, impeller::kDstOut, impeller::kDstOver, 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::kSrc, impeller::kSrcATop, impeller::kSrcIn, impeller::kSrcOut, impeller::kSrcOver, impeller::kXor, impeller::Luminosity(), impeller::Vector3::Max(), impeller::Min(), impeller::Vector3::Min(), Premultiply(), impeller::Saturation(), impeller::SetLuminosity(), impeller::SetSaturation(), impeller::Vector3::x, impeller::Vector3::y, and impeller::Vector3::z.

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

◆ Blue()

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

Definition at line 281 of file color.h.

281 { 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 319 of file color.h.

319  {
320  return {138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f};
321  }

◆ Brown()

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

Definition at line 323 of file color.h.

323  {
324  return {165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f};
325  }

◆ BurlyWood()

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

Definition at line 327 of file color.h.

327  {
328  return {222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f};
329  }

◆ CadetBlue()

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

Definition at line 331 of file color.h.

331  {
332  return {95.0f / 255.0f, 158.0f / 255.0f, 160.0f / 255.0f, 1.0f};
333  }

◆ Chartreuse()

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

Definition at line 335 of file color.h.

335  {
336  return {127.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
337  }

◆ Chocolate()

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

Definition at line 339 of file color.h.

339  {
340  return {210.0f / 255.0f, 105.0f / 255.0f, 30.0f / 255.0f, 1.0f};
341  }

◆ 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 343 of file color.h.

343  {
344  return {255.0f / 255.0f, 127.0f / 255.0f, 80.0f / 255.0f, 1.0f};
345  }

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

◆ CornflowerBlue()

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

Definition at line 347 of file color.h.

347  {
348  return {100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f};
349  }

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

◆ Cornsilk()

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

Definition at line 351 of file color.h.

351  {
352  return {255.0f / 255.0f, 248.0f / 255.0f, 220.0f / 255.0f, 1.0f};
353  }

◆ Crimson()

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

Definition at line 355 of file color.h.

355  {
356  return {220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f};
357  }

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

◆ Cyan()

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

Definition at line 359 of file color.h.

359  {
360  return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
361  }

◆ DarkBlue()

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

Definition at line 363 of file color.h.

363  {
364  return {0.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
365  }

◆ DarkCyan()

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

Definition at line 367 of file color.h.

367  {
368  return {0.0f / 255.0f, 139.0f / 255.0f, 139.0f / 255.0f, 1.0f};
369  }

◆ DarkGoldenrod()

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

Definition at line 371 of file color.h.

371  {
372  return {184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f};
373  }

◆ DarkGray()

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

Definition at line 375 of file color.h.

375  {
376  return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
377  }

◆ DarkGreen()

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

Definition at line 379 of file color.h.

379  {
380  return {0.0f / 255.0f, 100.0f / 255.0f, 0.0f / 255.0f, 1.0f};
381  }

◆ DarkGrey()

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

Definition at line 383 of file color.h.

383  {
384  return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
385  }

◆ DarkKhaki()

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

Definition at line 387 of file color.h.

387  {
388  return {189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f};
389  }

◆ DarkMagenta()

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

Definition at line 391 of file color.h.

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

◆ DarkOliveGreen()

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

Definition at line 395 of file color.h.

395  {
396  return {85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f};
397  }

◆ DarkOrange()

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

Definition at line 399 of file color.h.

399  {
400  return {255.0f / 255.0f, 140.0f / 255.0f, 0.0f / 255.0f, 1.0f};
401  }

◆ DarkOrchid()

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

Definition at line 403 of file color.h.

403  {
404  return {153.0f / 255.0f, 50.0f / 255.0f, 204.0f / 255.0f, 1.0f};
405  }

◆ DarkRed()

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

Definition at line 407 of file color.h.

407  {
408  return {139.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
409  }

◆ DarkSalmon()

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

Definition at line 411 of file color.h.

411  {
412  return {233.0f / 255.0f, 150.0f / 255.0f, 122.0f / 255.0f, 1.0f};
413  }

◆ DarkSeagreen()

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

Definition at line 415 of file color.h.

415  {
416  return {143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f};
417  }

◆ DarkSlateBlue()

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

Definition at line 419 of file color.h.

419  {
420  return {72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f};
421  }

◆ DarkSlateGray()

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

Definition at line 423 of file color.h.

423  {
424  return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
425  }

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

◆ DarkSlateGrey()

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

Definition at line 427 of file color.h.

427  {
428  return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
429  }

◆ DarkTurquoise()

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

Definition at line 431 of file color.h.

431  {
432  return {0.0f / 255.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f};
433  }

◆ DarkViolet()

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

Definition at line 435 of file color.h.

435  {
436  return {148.0f / 255.0f, 0.0f / 255.0f, 211.0f / 255.0f, 1.0f};
437  }

◆ DeepPink()

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

Definition at line 439 of file color.h.

439  {
440  return {255.0f / 255.0f, 20.0f / 255.0f, 147.0f / 255.0f, 1.0f};
441  }

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

◆ DeepSkyBlue()

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

Definition at line 443 of file color.h.

443  {
444  return {0.0f / 255.0f, 191.0f / 255.0f, 255.0f / 255.0f, 1.0f};
445  }

◆ DimGray()

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

Definition at line 447 of file color.h.

447  {
448  return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
449  }

◆ DimGrey()

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

Definition at line 451 of file color.h.

451  {
452  return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
453  }

◆ DodgerBlue()

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

Definition at line 455 of file color.h.

455  {
456  return {30.0f / 255.0f, 144.0f / 255.0f, 255.0f / 255.0f, 1.0f};
457  }

◆ Firebrick()

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

Definition at line 459 of file color.h.

459  {
460  return {178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f};
461  }

◆ FloralWhite()

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

Definition at line 463 of file color.h.

463  {
464  return {255.0f / 255.0f, 250.0f / 255.0f, 240.0f / 255.0f, 1.0f};
465  }

◆ ForestGreen()

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

Definition at line 467 of file color.h.

467  {
468  return {34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f};
469  }

◆ Fuchsia()

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

Definition at line 471 of file color.h.

471  {
472  return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
473  }

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

◆ Gainsboro()

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

Definition at line 475 of file color.h.

475  {
476  return {220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f, 1.0f};
477  }

◆ Ghostwhite()

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

Definition at line 479 of file color.h.

479  {
480  return {248.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
481  }

◆ Gold()

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

Definition at line 483 of file color.h.

483  {
484  return {255.0f / 255.0f, 215.0f / 255.0f, 0.0f / 255.0f, 1.0f};
485  }

◆ Goldenrod()

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

Definition at line 487 of file color.h.

487  {
488  return {218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f};
489  }

◆ Gray()

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

Definition at line 491 of file color.h.

491  {
492  return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
493  }

◆ Green()

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

Definition at line 279 of file color.h.

279 { 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 495 of file color.h.

495  {
496  return {173.0f / 255.0f, 255.0f / 255.0f, 47.0f / 255.0f, 1.0f};
497  }

◆ Grey()

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

Definition at line 499 of file color.h.

499  {
500  return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
501  }

◆ Honeydew()

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

Definition at line 503 of file color.h.

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

◆ HotPink()

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

Definition at line 507 of file color.h.

507  {
508  return {255.0f / 255.0f, 105.0f / 255.0f, 180.0f / 255.0f, 1.0f};
509  }

◆ IndianRed()

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

Definition at line 511 of file color.h.

511  {
512  return {205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f};
513  }

◆ Indigo()

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

Definition at line 515 of file color.h.

515  {
516  return {75.0f / 255.0f, 0.0f / 255.0f, 130.0f / 255.0f, 1.0f};
517  }

◆ IsOpaque()

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

Definition at line 899 of file color.h.

899 { return alpha == 1.0f; }

References alpha.

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

◆ IsTransparent()

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

Definition at line 897 of file color.h.

897 { return alpha == 0.0f; }

References alpha.

Referenced by impeller::TextContents::Render().

◆ Ivory()

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

Definition at line 519 of file color.h.

519  {
520  return {255.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
521  }

◆ Khaki()

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

Definition at line 523 of file color.h.

523  {
524  return {240.0f / 255.0f, 230.0f / 255.0f, 140.0f / 255.0f, 1.0f};
525  }

◆ Lavender()

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

Definition at line 527 of file color.h.

527  {
528  return {230.0f / 255.0f, 230.0f / 255.0f, 250.0f / 255.0f, 1.0f};
529  }

◆ LavenderBlush()

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

Definition at line 531 of file color.h.

531  {
532  return {255.0f / 255.0f, 240.0f / 255.0f, 245.0f / 255.0f, 1.0f};
533  }

◆ LawnGreen()

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

Definition at line 535 of file color.h.

535  {
536  return {124.0f / 255.0f, 252.0f / 255.0f, 0.0f / 255.0f, 1.0f};
537  }

◆ LemonChiffon()

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

Definition at line 539 of file color.h.

539  {
540  return {255.0f / 255.0f, 250.0f / 255.0f, 205.0f / 255.0f, 1.0f};
541  }

◆ 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  }

References impeller::saturated::b.

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

◆ LightBlue()

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

Definition at line 543 of file color.h.

543  {
544  return {173.0f / 255.0f, 216.0f / 255.0f, 230.0f / 255.0f, 1.0f};
545  }

◆ LightCoral()

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

Definition at line 547 of file color.h.

547  {
548  return {240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
549  }

◆ LightCyan()

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

Definition at line 551 of file color.h.

551  {
552  return {224.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
553  }

◆ LightGoldenrodYellow()

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

Definition at line 555 of file color.h.

555  {
556  return {50.0f / 255.0f, 250.0f / 255.0f, 210.0f / 255.0f, 1.0f};
557  }

◆ LightGray()

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

Definition at line 559 of file color.h.

559  {
560  return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
561  }

◆ LightGreen()

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

Definition at line 563 of file color.h.

563  {
564  return {144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f};
565  }

◆ LightGrey()

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

Definition at line 567 of file color.h.

567  {
568  return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
569  }

◆ LightPink()

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

Definition at line 571 of file color.h.

571  {
572  return {255.0f / 255.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f};
573  }

◆ LightSalmon()

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

Definition at line 575 of file color.h.

575  {
576  return {255.0f / 255.0f, 160.0f / 255.0f, 122.0f / 255.0f, 1.0f};
577  }

◆ LightSeaGreen()

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

Definition at line 579 of file color.h.

579  {
580  return {32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f};
581  }

◆ LightSkyBlue()

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

Definition at line 583 of file color.h.

583  {
584  return {135.0f / 255.0f, 206.0f / 255.0f, 250.0f / 255.0f, 1.0f};
585  }

◆ LightSlateGray()

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

Definition at line 587 of file color.h.

587  {
588  return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
589  }

◆ LightSlateGrey()

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

Definition at line 591 of file color.h.

591  {
592  return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
593  }

◆ LightSteelBlue()

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

Definition at line 595 of file color.h.

595  {
596  return {176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f};
597  }

◆ LightYellow()

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

Definition at line 599 of file color.h.

599  {
600  return {255.0f / 255.0f, 255.0f / 255.0f, 224.0f / 255.0f, 1.0f};
601  }

◆ Lime()

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

Definition at line 603 of file color.h.

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

◆ LimeGreen()

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

Definition at line 607 of file color.h.

607  {
608  return {50.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
609  }

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

◆ 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 309 of file color.cc.

309  {
310  static auto conversion = [](Scalar component) {
311  if (component <= 0.0031308) {
312  return component * 12.92;
313  }
314  return 1.055 * pow(component, (1.0 / 2.4)) - 0.055;
315  };
316 
317  return Color(conversion(red), conversion(green), conversion(blue), alpha);
318 }

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

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

◆ Linen()

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

Definition at line 611 of file color.h.

611  {
612  return {250.0f / 255.0f, 240.0f / 255.0f, 230.0f / 255.0f, 1.0f};
613  }

◆ Magenta()

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

Definition at line 615 of file color.h.

615  {
616  return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
617  }

◆ 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 impeller::saturated::b, and Color().

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

◆ Maroon()

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

Definition at line 619 of file color.h.

619  {
620  return {128.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
621  }

◆ MediumAquamarine()

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

Definition at line 623 of file color.h.

623  {
624  return {102.0f / 255.0f, 205.0f / 255.0f, 170.0f / 255.0f, 1.0f};
625  }

◆ MediumBlue()

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

Definition at line 627 of file color.h.

627  {
628  return {0.0f / 255.0f, 0.0f / 255.0f, 205.0f / 255.0f, 1.0f};
629  }

◆ MediumOrchid()

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

Definition at line 631 of file color.h.

631  {
632  return {186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f};
633  }

◆ MediumPurple()

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

Definition at line 635 of file color.h.

635  {
636  return {147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f};
637  }

◆ MediumSeagreen()

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

Definition at line 639 of file color.h.

639  {
640  return {60.0f / 255.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f};
641  }

◆ MediumSlateBlue()

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

Definition at line 643 of file color.h.

643  {
644  return {123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f};
645  }

◆ MediumSpringGreen()

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

Definition at line 647 of file color.h.

647  {
648  return {0.0f / 255.0f, 250.0f / 255.0f, 154.0f / 255.0f, 1.0f};
649  }

◆ MediumTurquoise()

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

Definition at line 651 of file color.h.

651  {
652  return {72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f};
653  }

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

◆ MediumVioletRed()

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

Definition at line 655 of file color.h.

655  {
656  return {199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f};
657  }

◆ MidnightBlue()

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

Definition at line 659 of file color.h.

659  {
660  return {25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f};
661  }

◆ MintCream()

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

Definition at line 663 of file color.h.

663  {
664  return {245.0f / 255.0f, 255.0f / 255.0f, 250.0f / 255.0f, 1.0f};
665  }

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

◆ MistyRose()

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

Definition at line 667 of file color.h.

667  {
668  return {255.0f / 255.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f};
669  }

◆ Moccasin()

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

Definition at line 671 of file color.h.

671  {
672  return {255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f};
673  }

◆ NavajoWhite()

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

Definition at line 675 of file color.h.

675  {
676  return {255.0f / 255.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f};
677  }

◆ Navy()

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

Definition at line 679 of file color.h.

679  {
680  return {0.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
681  }

◆ OldLace()

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

Definition at line 683 of file color.h.

683  {
684  return {253.0f / 255.0f, 245.0f / 255.0f, 230.0f / 255.0f, 1.0f};
685  }

◆ Olive()

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

Definition at line 687 of file color.h.

687  {
688  return {128.0f / 255.0f, 128.0f / 255.0f, 0.0f / 255.0f, 1.0f};
689  }

◆ OliveDrab()

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

Definition at line 691 of file color.h.

691  {
692  return {107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f};
693  }

◆ 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, c, green, and red.

◆ operator*() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator* ( T  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, red, and value.

◆ 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, c, green, and red.

◆ operator+() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator+ ( T  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, red, and value.

◆ 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, c, green, and red.

◆ operator-() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator- ( T  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, red, and value.

◆ 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, c, green, and red.

◆ operator/() [2/2]

template<class T , class = std::enable_if_t<std::is_arithmetic_v<T>>>
constexpr Color impeller::Color::operator/ ( T  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, red, and value.

◆ 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  }
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
Definition: scalar.h:36

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

◆ Orange()

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

Definition at line 695 of file color.h.

695  {
696  return {255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f};
697  }

◆ OrangeRed()

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

Definition at line 699 of file color.h.

699  {
700  return {255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f};
701  }

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

◆ Orchid()

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

Definition at line 703 of file color.h.

703  {
704  return {218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f};
705  }

◆ PaleGoldenrod()

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

Definition at line 707 of file color.h.

707  {
708  return {238.0f / 255.0f, 232.0f / 255.0f, 170.0f / 255.0f, 1.0f};
709  }

◆ PaleGreen()

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

Definition at line 711 of file color.h.

711  {
712  return {152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f};
713  }

◆ PaleTurquoise()

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

Definition at line 715 of file color.h.

715  {
716  return {175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f};
717  }

◆ PaleVioletRed()

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

Definition at line 719 of file color.h.

719  {
720  return {219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f};
721  }

◆ PapayaWhip()

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

Definition at line 723 of file color.h.

723  {
724  return {255.0f / 255.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f};
725  }

◆ Peachpuff()

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

Definition at line 727 of file color.h.

727  {
728  return {255.0f / 255.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f};
729  }

◆ Peru()

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

Definition at line 731 of file color.h.

731  {
732  return {205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f};
733  }

◆ Pink()

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

Definition at line 735 of file color.h.

735  {
736  return {255.0f / 255.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f};
737  }

◆ Plum()

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

Definition at line 739 of file color.h.

739  {
740  return {221.0f / 255.0f, 160.0f / 255.0f, 221.0f / 255.0f, 1.0f};
741  }

◆ PowderBlue()

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

Definition at line 743 of file color.h.

743  {
744  return {176.0f / 255.0f, 224.0f / 255.0f, 230.0f / 255.0f, 1.0f};
745  }

◆ Premultiply()

◆ Purple()

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

Definition at line 747 of file color.h.

747  {
748  return {128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
749  }

◆ Random()

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

Definition at line 855 of file color.h.

855  {
856  return {
857  // This method is not used for cryptographic purposes.
858  // NOLINTBEGIN(clang-analyzer-security.insecureAPI.rand)
859  static_cast<Scalar>((std::rand() % 255) / 255.0f), //
860  static_cast<Scalar>((std::rand() % 255) / 255.0f), //
861  static_cast<Scalar>((std::rand() % 255) / 255.0f), //
862  // NOLINTEND(clang-analyzer-security.insecureAPI.rand)
863  1.0f //
864 
865  };
866  }

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

◆ Red()

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

Definition at line 277 of file color.h.

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

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

◆ RosyBrown()

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

Definition at line 751 of file color.h.

751  {
752  return {188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f};
753  }

◆ RoyalBlue()

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

Definition at line 755 of file color.h.

755  {
756  return {65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f};
757  }

◆ SaddleBrown()

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

Definition at line 759 of file color.h.

759  {
760  return {139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f};
761  }

◆ Salmon()

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

Definition at line 763 of file color.h.

763  {
764  return {250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f};
765  }

◆ SandyBrown()

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

Definition at line 767 of file color.h.

767  {
768  return {244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f};
769  }

◆ Seagreen()

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

Definition at line 771 of file color.h.

771  {
772  return {46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f};
773  }

◆ Seashell()

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

Definition at line 775 of file color.h.

775  {
776  return {255.0f / 255.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f};
777  }

◆ Sienna()

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

Definition at line 779 of file color.h.

779  {
780  return {160.0f / 255.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f};
781  }

◆ Silver()

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

Definition at line 783 of file color.h.

783  {
784  return {192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f};
785  }

◆ SkyBlue()

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

Definition at line 787 of file color.h.

787  {
788  return {135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f};
789  }

◆ SlateBlue()

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

Definition at line 791 of file color.h.

791  {
792  return {106.0f / 255.0f, 90.0f / 255.0f, 205.0f / 255.0f, 1.0f};
793  }

◆ SlateGray()

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

Definition at line 795 of file color.h.

795  {
796  return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
797  }

◆ SlateGrey()

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

Definition at line 799 of file color.h.

799  {
800  return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
801  }

◆ Snow()

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

Definition at line 803 of file color.h.

803  {
804  return {255.0f / 255.0f, 250.0f / 255.0f, 250.0f / 255.0f, 1.0f};
805  }

◆ SpringGreen()

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

Definition at line 807 of file color.h.

807  {
808  return {0.0f / 255.0f, 255.0f / 255.0f, 127.0f / 255.0f, 1.0f};
809  }

◆ 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 320 of file color.cc.

320  {
321  static auto conversion = [](Scalar component) {
322  if (component <= 0.04045) {
323  return component / 12.92;
324  }
325  return pow((component + 0.055) / 1.055, 2.4);
326  };
327 
328  return Color(conversion(red), conversion(green), conversion(blue), alpha);
329 }

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

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

◆ SteelBlue()

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

Definition at line 811 of file color.h.

811  {
812  return {70.0f / 255.0f, 130.0f / 255.0f, 180.0f / 255.0f, 1.0f};
813  }

◆ Tan()

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

Definition at line 815 of file color.h.

815  {
816  return {210.0f / 255.0f, 180.0f / 255.0f, 140.0f / 255.0f, 1.0f};
817  }

◆ Teal()

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

Definition at line 819 of file color.h.

819  {
820  return {0.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
821  }

◆ Thistle()

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

Definition at line 823 of file color.h.

823  {
824  return {216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f};
825  }

◆ ToARGB()

uint32_t impeller::Color::ToARGB ( ) const
inline

Convert to ARGB 32 bit color.

Returns
constexpr uint32_t

Definition at line 259 of file color.h.

259  {
260  std::array<uint8_t, 4> result = ToR8G8B8A8();
261  return result[3] << 24 | result[0] << 16 | result[1] << 8 | result[2];
262  }
std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
Definition: color.h:246

References ToR8G8B8A8().

Referenced by impeller::testing::CanRenderConicalGradientWithDithering(), impeller::testing::CanRenderRadialGradientWithDithering(), impeller::testing::CanRenderSweepGradientWithDithering(), impeller::TextShadowCache::TextShadowCacheKey::Hash::operator()(), and impeller::testing::TEST_P().

◆ ToIColor()

static uint32_t impeller::Color::ToIColor ( Color  color)
inlinestatic

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::testing::TEST(), and impeller::testing::toColor().

◆ Tomato()

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

Definition at line 827 of file color.h.

827  {
828  return {255.0f / 255.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f};
829  }

◆ ToR8G8B8A8()

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

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, impeller::saturated::b, blue, green, and red.

Referenced by impeller::AppendColor(), impeller::ContentContext::ContentContext(), impeller::testing::TEST(), impeller::interop::testing::TEST_P(), and ToARGB().

◆ Turquoise()

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

Definition at line 831 of file color.h.

831  {
832  return {64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f};
833  }

◆ 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(), impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ Violet()

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

Definition at line 835 of file color.h.

835  {
836  return {238.0f / 255.0f, 130.0f / 255.0f, 238.0f / 255.0f, 1.0f};
837  }

◆ Wheat()

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

Definition at line 839 of file color.h.

839  {
840  return {245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f};
841  }

◆ White()

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

◆ Whitesmoke()

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

Definition at line 843 of file color.h.

843  {
844  return {245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f};
845  }

◆ WhiteTransparent()

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

Definition at line 273 of file color.h.

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

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

◆ WithAlpha()

◆ Yellow()

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

Definition at line 847 of file color.h.

847  {
848  return {255.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
849  }

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

◆ YellowGreen()

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

Definition at line 851 of file color.h.

851  {
852  return {154.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
853  }

Friends And Related Function Documentation

◆ AbslHashValue

template<typename H >
H AbslHashValue ( H  h,
const Color &  c 
)
friend

Definition at line 265 of file color.h.

265  {
266  return H::combine(std::move(h), c.ToARGB());
267  }

Member Data Documentation

◆ alpha

◆ blue

◆ green

◆ red


The documentation for this struct was generated from the following files: