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
 

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

53  : 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 282 of file color.h.

282  {
283  return {240.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
284  }

◆ AntiqueWhite()

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

Definition at line 286 of file color.h.

286  {
287  return {250.0f / 255.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f};
288  }

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

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

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

290  {
291  return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
292  }

◆ AquaMarine()

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

Definition at line 294 of file color.h.

294  {
295  return {127.0f / 255.0f, 255.0f / 255.0f, 212.0f / 255.0f, 1.0f};
296  }

◆ Azure()

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

Definition at line 298 of file color.h.

298  {
299  return {240.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
300  }

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

◆ Beige()

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

Definition at line 302 of file color.h.

302  {
303  return {245.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f, 1.0f};
304  }

◆ Bisque()

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

Definition at line 306 of file color.h.

306  {
307  return {255.0f / 255.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f};
308  }

◆ Black()

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

Definition at line 266 of file color.h.

266 { 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 310 of file color.h.

310  {
311  return {255.0f / 255.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f};
312  }

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

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

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

276 { 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 314 of file color.h.

314  {
315  return {138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f};
316  }

◆ Brown()

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

Definition at line 318 of file color.h.

318  {
319  return {165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f};
320  }

◆ BurlyWood()

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

Definition at line 322 of file color.h.

322  {
323  return {222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f};
324  }

◆ CadetBlue()

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

Definition at line 326 of file color.h.

326  {
327  return {95.0f / 255.0f, 158.0f / 255.0f, 160.0f / 255.0f, 1.0f};
328  }

◆ Chartreuse()

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

Definition at line 330 of file color.h.

330  {
331  return {127.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
332  }

◆ Chocolate()

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

Definition at line 334 of file color.h.

334  {
335  return {210.0f / 255.0f, 105.0f / 255.0f, 30.0f / 255.0f, 1.0f};
336  }

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

338  {
339  return {255.0f / 255.0f, 127.0f / 255.0f, 80.0f / 255.0f, 1.0f};
340  }

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

◆ CornflowerBlue()

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

Definition at line 342 of file color.h.

342  {
343  return {100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f};
344  }

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

◆ Cornsilk()

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

Definition at line 346 of file color.h.

346  {
347  return {255.0f / 255.0f, 248.0f / 255.0f, 220.0f / 255.0f, 1.0f};
348  }

◆ Crimson()

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

Definition at line 350 of file color.h.

350  {
351  return {220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f};
352  }

◆ Cyan()

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

Definition at line 354 of file color.h.

354  {
355  return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
356  }

◆ DarkBlue()

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

Definition at line 358 of file color.h.

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

◆ DarkCyan()

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

Definition at line 362 of file color.h.

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

◆ DarkGoldenrod()

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

Definition at line 366 of file color.h.

366  {
367  return {184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f};
368  }

◆ DarkGray()

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

Definition at line 370 of file color.h.

370  {
371  return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
372  }

◆ DarkGreen()

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

Definition at line 374 of file color.h.

374  {
375  return {0.0f / 255.0f, 100.0f / 255.0f, 0.0f / 255.0f, 1.0f};
376  }

◆ DarkGrey()

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

Definition at line 378 of file color.h.

378  {
379  return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
380  }

◆ DarkKhaki()

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

Definition at line 382 of file color.h.

382  {
383  return {189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f};
384  }

◆ DarkMagenta()

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

Definition at line 386 of file color.h.

386  {
387  return {139.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
388  }

◆ DarkOliveGreen()

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

Definition at line 390 of file color.h.

390  {
391  return {85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f};
392  }

◆ DarkOrange()

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

Definition at line 394 of file color.h.

394  {
395  return {255.0f / 255.0f, 140.0f / 255.0f, 0.0f / 255.0f, 1.0f};
396  }

◆ DarkOrchid()

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

Definition at line 398 of file color.h.

398  {
399  return {153.0f / 255.0f, 50.0f / 255.0f, 204.0f / 255.0f, 1.0f};
400  }

◆ DarkRed()

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

Definition at line 402 of file color.h.

402  {
403  return {139.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
404  }

◆ DarkSalmon()

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

Definition at line 406 of file color.h.

406  {
407  return {233.0f / 255.0f, 150.0f / 255.0f, 122.0f / 255.0f, 1.0f};
408  }

◆ DarkSeagreen()

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

Definition at line 410 of file color.h.

410  {
411  return {143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f};
412  }

◆ DarkSlateBlue()

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

Definition at line 414 of file color.h.

414  {
415  return {72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f};
416  }

◆ DarkSlateGray()

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

Definition at line 418 of file color.h.

418  {
419  return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
420  }

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

◆ DarkSlateGrey()

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

Definition at line 422 of file color.h.

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

◆ DarkTurquoise()

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

Definition at line 426 of file color.h.

426  {
427  return {0.0f / 255.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f};
428  }

◆ DarkViolet()

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

Definition at line 430 of file color.h.

430  {
431  return {148.0f / 255.0f, 0.0f / 255.0f, 211.0f / 255.0f, 1.0f};
432  }

◆ DeepPink()

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

Definition at line 434 of file color.h.

434  {
435  return {255.0f / 255.0f, 20.0f / 255.0f, 147.0f / 255.0f, 1.0f};
436  }

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

◆ DeepSkyBlue()

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

Definition at line 438 of file color.h.

438  {
439  return {0.0f / 255.0f, 191.0f / 255.0f, 255.0f / 255.0f, 1.0f};
440  }

◆ DimGray()

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

Definition at line 442 of file color.h.

442  {
443  return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
444  }

◆ DimGrey()

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

Definition at line 446 of file color.h.

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

◆ DodgerBlue()

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

Definition at line 450 of file color.h.

450  {
451  return {30.0f / 255.0f, 144.0f / 255.0f, 255.0f / 255.0f, 1.0f};
452  }

◆ Firebrick()

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

Definition at line 454 of file color.h.

454  {
455  return {178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f};
456  }

◆ FloralWhite()

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

Definition at line 458 of file color.h.

458  {
459  return {255.0f / 255.0f, 250.0f / 255.0f, 240.0f / 255.0f, 1.0f};
460  }

◆ ForestGreen()

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

Definition at line 462 of file color.h.

462  {
463  return {34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f};
464  }

◆ Fuchsia()

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

Definition at line 466 of file color.h.

466  {
467  return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
468  }

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

◆ Gainsboro()

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

Definition at line 470 of file color.h.

470  {
471  return {220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f, 1.0f};
472  }

◆ Ghostwhite()

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

Definition at line 474 of file color.h.

474  {
475  return {248.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
476  }

◆ Gold()

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

Definition at line 478 of file color.h.

478  {
479  return {255.0f / 255.0f, 215.0f / 255.0f, 0.0f / 255.0f, 1.0f};
480  }

◆ Goldenrod()

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

Definition at line 482 of file color.h.

482  {
483  return {218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f};
484  }

◆ Gray()

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

Definition at line 486 of file color.h.

486  {
487  return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
488  }

◆ Green()

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

Definition at line 274 of file color.h.

274 { 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 490 of file color.h.

490  {
491  return {173.0f / 255.0f, 255.0f / 255.0f, 47.0f / 255.0f, 1.0f};
492  }

◆ Grey()

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

Definition at line 494 of file color.h.

494  {
495  return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
496  }

◆ Honeydew()

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

Definition at line 498 of file color.h.

498  {
499  return {240.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
500  }

◆ HotPink()

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

Definition at line 502 of file color.h.

502  {
503  return {255.0f / 255.0f, 105.0f / 255.0f, 180.0f / 255.0f, 1.0f};
504  }

◆ IndianRed()

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

Definition at line 506 of file color.h.

506  {
507  return {205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f};
508  }

◆ Indigo()

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

Definition at line 510 of file color.h.

510  {
511  return {75.0f / 255.0f, 0.0f / 255.0f, 130.0f / 255.0f, 1.0f};
512  }

◆ IsOpaque()

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

Definition at line 894 of file color.h.

894 { return alpha == 1.0f; }

References alpha.

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

◆ IsTransparent()

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

Definition at line 892 of file color.h.

892 { return alpha == 0.0f; }

References alpha.

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

◆ Ivory()

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

Definition at line 514 of file color.h.

514  {
515  return {255.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
516  }

◆ Khaki()

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

Definition at line 518 of file color.h.

518  {
519  return {240.0f / 255.0f, 230.0f / 255.0f, 140.0f / 255.0f, 1.0f};
520  }

◆ Lavender()

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

Definition at line 522 of file color.h.

522  {
523  return {230.0f / 255.0f, 230.0f / 255.0f, 250.0f / 255.0f, 1.0f};
524  }

◆ LavenderBlush()

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

Definition at line 526 of file color.h.

526  {
527  return {255.0f / 255.0f, 240.0f / 255.0f, 245.0f / 255.0f, 1.0f};
528  }

◆ LawnGreen()

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

Definition at line 530 of file color.h.

530  {
531  return {124.0f / 255.0f, 252.0f / 255.0f, 0.0f / 255.0f, 1.0f};
532  }

◆ LemonChiffon()

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

Definition at line 534 of file color.h.

534  {
535  return {255.0f / 255.0f, 250.0f / 255.0f, 205.0f / 255.0f, 1.0f};
536  }

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

◆ LightBlue()

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

Definition at line 538 of file color.h.

538  {
539  return {173.0f / 255.0f, 216.0f / 255.0f, 230.0f / 255.0f, 1.0f};
540  }

◆ LightCoral()

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

Definition at line 542 of file color.h.

542  {
543  return {240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
544  }

◆ LightCyan()

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

Definition at line 546 of file color.h.

546  {
547  return {224.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
548  }

◆ LightGoldenrodYellow()

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

Definition at line 550 of file color.h.

550  {
551  return {50.0f / 255.0f, 250.0f / 255.0f, 210.0f / 255.0f, 1.0f};
552  }

◆ LightGray()

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

Definition at line 554 of file color.h.

554  {
555  return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
556  }

◆ LightGreen()

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

Definition at line 558 of file color.h.

558  {
559  return {144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f};
560  }

◆ LightGrey()

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

Definition at line 562 of file color.h.

562  {
563  return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
564  }

◆ LightPink()

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

Definition at line 566 of file color.h.

566  {
567  return {255.0f / 255.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f};
568  }

◆ LightSalmon()

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

Definition at line 570 of file color.h.

570  {
571  return {255.0f / 255.0f, 160.0f / 255.0f, 122.0f / 255.0f, 1.0f};
572  }

◆ LightSeaGreen()

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

Definition at line 574 of file color.h.

574  {
575  return {32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f};
576  }

◆ LightSkyBlue()

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

Definition at line 578 of file color.h.

578  {
579  return {135.0f / 255.0f, 206.0f / 255.0f, 250.0f / 255.0f, 1.0f};
580  }

◆ LightSlateGray()

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

Definition at line 582 of file color.h.

582  {
583  return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
584  }

◆ LightSlateGrey()

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

Definition at line 586 of file color.h.

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

◆ LightSteelBlue()

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

Definition at line 590 of file color.h.

590  {
591  return {176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f};
592  }

◆ LightYellow()

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

Definition at line 594 of file color.h.

594  {
595  return {255.0f / 255.0f, 255.0f / 255.0f, 224.0f / 255.0f, 1.0f};
596  }

◆ Lime()

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

Definition at line 598 of file color.h.

598  {
599  return {0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
600  }

◆ LimeGreen()

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

Definition at line 602 of file color.h.

602  {
603  return {50.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
604  }

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

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

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

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

◆ Linen()

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

Definition at line 606 of file color.h.

606  {
607  return {250.0f / 255.0f, 240.0f / 255.0f, 230.0f / 255.0f, 1.0f};
608  }

◆ Magenta()

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

Definition at line 610 of file color.h.

610  {
611  return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
612  }

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

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

◆ MediumAquamarine()

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

Definition at line 618 of file color.h.

618  {
619  return {102.0f / 255.0f, 205.0f / 255.0f, 170.0f / 255.0f, 1.0f};
620  }

◆ MediumBlue()

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

Definition at line 622 of file color.h.

622  {
623  return {0.0f / 255.0f, 0.0f / 255.0f, 205.0f / 255.0f, 1.0f};
624  }

◆ MediumOrchid()

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

Definition at line 626 of file color.h.

626  {
627  return {186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f};
628  }

◆ MediumPurple()

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

Definition at line 630 of file color.h.

630  {
631  return {147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f};
632  }

◆ MediumSeagreen()

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

Definition at line 634 of file color.h.

634  {
635  return {60.0f / 255.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f};
636  }

◆ MediumSlateBlue()

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

Definition at line 638 of file color.h.

638  {
639  return {123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f};
640  }

◆ MediumSpringGreen()

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

Definition at line 642 of file color.h.

642  {
643  return {0.0f / 255.0f, 250.0f / 255.0f, 154.0f / 255.0f, 1.0f};
644  }

◆ MediumTurquoise()

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

Definition at line 646 of file color.h.

646  {
647  return {72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f};
648  }

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

◆ MediumVioletRed()

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

Definition at line 650 of file color.h.

650  {
651  return {199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f};
652  }

◆ MidnightBlue()

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

Definition at line 654 of file color.h.

654  {
655  return {25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f};
656  }

◆ MintCream()

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

Definition at line 658 of file color.h.

658  {
659  return {245.0f / 255.0f, 255.0f / 255.0f, 250.0f / 255.0f, 1.0f};
660  }

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

◆ MistyRose()

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

Definition at line 662 of file color.h.

662  {
663  return {255.0f / 255.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f};
664  }

◆ Moccasin()

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

Definition at line 666 of file color.h.

666  {
667  return {255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f};
668  }

◆ NavajoWhite()

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

Definition at line 670 of file color.h.

670  {
671  return {255.0f / 255.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f};
672  }

◆ Navy()

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

Definition at line 674 of file color.h.

674  {
675  return {0.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
676  }

◆ OldLace()

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

Definition at line 678 of file color.h.

678  {
679  return {253.0f / 255.0f, 245.0f / 255.0f, 230.0f / 255.0f, 1.0f};
680  }

◆ Olive()

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

Definition at line 682 of file color.h.

682  {
683  return {128.0f / 255.0f, 128.0f / 255.0f, 0.0f / 255.0f, 1.0f};
684  }

◆ OliveDrab()

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

Definition at line 686 of file color.h.

686  {
687  return {107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f};
688  }

◆ 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, 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, 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, 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, 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, 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, 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, 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, green, red, and impeller::ScalarNearlyEqual().

◆ Orange()

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

Definition at line 690 of file color.h.

690  {
691  return {255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f};
692  }

◆ OrangeRed()

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

Definition at line 694 of file color.h.

694  {
695  return {255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f};
696  }

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

◆ Orchid()

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

Definition at line 698 of file color.h.

698  {
699  return {218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f};
700  }

◆ PaleGoldenrod()

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

Definition at line 702 of file color.h.

702  {
703  return {238.0f / 255.0f, 232.0f / 255.0f, 170.0f / 255.0f, 1.0f};
704  }

◆ PaleGreen()

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

Definition at line 706 of file color.h.

706  {
707  return {152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f};
708  }

◆ PaleTurquoise()

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

Definition at line 710 of file color.h.

710  {
711  return {175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f};
712  }

◆ PaleVioletRed()

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

Definition at line 714 of file color.h.

714  {
715  return {219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f};
716  }

◆ PapayaWhip()

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

Definition at line 718 of file color.h.

718  {
719  return {255.0f / 255.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f};
720  }

◆ Peachpuff()

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

Definition at line 722 of file color.h.

722  {
723  return {255.0f / 255.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f};
724  }

◆ Peru()

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

Definition at line 726 of file color.h.

726  {
727  return {205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f};
728  }

◆ Pink()

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

Definition at line 730 of file color.h.

730  {
731  return {255.0f / 255.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f};
732  }

◆ Plum()

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

Definition at line 734 of file color.h.

734  {
735  return {221.0f / 255.0f, 160.0f / 255.0f, 221.0f / 255.0f, 1.0f};
736  }

◆ PowderBlue()

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

Definition at line 738 of file color.h.

738  {
739  return {176.0f / 255.0f, 224.0f / 255.0f, 230.0f / 255.0f, 1.0f};
740  }

◆ Premultiply()

◆ Purple()

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

Definition at line 742 of file color.h.

742  {
743  return {128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
744  }

◆ Random()

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

Definition at line 850 of file color.h.

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

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

◆ Red()

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

Definition at line 272 of file color.h.

272 { 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 746 of file color.h.

746  {
747  return {188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f};
748  }

◆ RoyalBlue()

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

Definition at line 750 of file color.h.

750  {
751  return {65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f};
752  }

◆ SaddleBrown()

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

Definition at line 754 of file color.h.

754  {
755  return {139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f};
756  }

◆ Salmon()

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

Definition at line 758 of file color.h.

758  {
759  return {250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f};
760  }

◆ SandyBrown()

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

Definition at line 762 of file color.h.

762  {
763  return {244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f};
764  }

◆ Seagreen()

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

Definition at line 766 of file color.h.

766  {
767  return {46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f};
768  }

◆ Seashell()

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

Definition at line 770 of file color.h.

770  {
771  return {255.0f / 255.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f};
772  }

◆ Sienna()

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

Definition at line 774 of file color.h.

774  {
775  return {160.0f / 255.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f};
776  }

◆ Silver()

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

Definition at line 778 of file color.h.

778  {
779  return {192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f};
780  }

◆ SkyBlue()

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

Definition at line 782 of file color.h.

782  {
783  return {135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f};
784  }

◆ SlateBlue()

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

Definition at line 786 of file color.h.

786  {
787  return {106.0f / 255.0f, 90.0f / 255.0f, 205.0f / 255.0f, 1.0f};
788  }

◆ SlateGray()

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

Definition at line 790 of file color.h.

790  {
791  return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
792  }

◆ SlateGrey()

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

Definition at line 794 of file color.h.

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

◆ Snow()

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

Definition at line 798 of file color.h.

798  {
799  return {255.0f / 255.0f, 250.0f / 255.0f, 250.0f / 255.0f, 1.0f};
800  }

◆ SpringGreen()

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

Definition at line 802 of file color.h.

802  {
803  return {0.0f / 255.0f, 255.0f / 255.0f, 127.0f / 255.0f, 1.0f};
804  }

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

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

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

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

◆ SteelBlue()

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

Definition at line 806 of file color.h.

806  {
807  return {70.0f / 255.0f, 130.0f / 255.0f, 180.0f / 255.0f, 1.0f};
808  }

◆ Tan()

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

Definition at line 810 of file color.h.

810  {
811  return {210.0f / 255.0f, 180.0f / 255.0f, 140.0f / 255.0f, 1.0f};
812  }

◆ Teal()

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

Definition at line 814 of file color.h.

814  {
815  return {0.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
816  }

◆ Thistle()

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

Definition at line 818 of file color.h.

818  {
819  return {216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f};
820  }

◆ 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::GlyphProperties::Equal::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 822 of file color.h.

822  {
823  return {255.0f / 255.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f};
824  }

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

826  {
827  return {64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f};
828  }

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

830  {
831  return {238.0f / 255.0f, 130.0f / 255.0f, 238.0f / 255.0f, 1.0f};
832  }

◆ Wheat()

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

Definition at line 834 of file color.h.

834  {
835  return {245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f};
836  }

◆ White()

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

Definition at line 264 of file color.h.

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

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

◆ Whitesmoke()

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

Definition at line 838 of file color.h.

838  {
839  return {245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f};
840  }

◆ WhiteTransparent()

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

Definition at line 268 of file color.h.

268 { 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 842 of file color.h.

842  {
843  return {255.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
844  }

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

◆ YellowGreen()

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

Definition at line 846 of file color.h.

846  {
847  return {154.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
848  }

Member Data Documentation

◆ alpha

◆ blue

◆ green

◆ red


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