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

Public Attributes

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

Detailed Description

Represents a RGBA color

Definition at line 123 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/3]

constexpr impeller::Color::Color ( )
inlineconstexpr

Definition at line 144 of file color.h.

144 {}

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

◆ Color() [3/3]

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

Definition at line 148 of file color.h.

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

Member Function Documentation

◆ AliceBlue()

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

Definition at line 281 of file color.h.

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

◆ AntiqueWhite()

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

Definition at line 285 of file color.h.

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

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 }

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

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

◆ AquaMarine()

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

Definition at line 293 of file color.h.

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

◆ Azure()

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

Definition at line 297 of file color.h.

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

◆ Beige()

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

Definition at line 301 of file color.h.

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

◆ Bisque()

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

Definition at line 305 of file color.h.

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

◆ Black()

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

Definition at line 265 of file color.h.

265 { 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 309 of file color.h.

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

◆ 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::kSource:
164  return src;
166  return dst;
168  // r = s + (1-sa)*d
169  return (src.Premultiply() + dst.Premultiply() * (1 - src.alpha))
170  .Unpremultiply();
172  // r = d + (1-da)*s
173  return (dst.Premultiply() + src.Premultiply() * (1 - dst.alpha))
174  .Unpremultiply();
176  // r = s * da
177  return (src.Premultiply() * dst.alpha).Unpremultiply();
179  // r = d * sa
180  return (dst.Premultiply() * src.alpha).Unpremultiply();
182  // r = s * ( 1- da)
183  return (src.Premultiply() * (1 - dst.alpha)).Unpremultiply();
185  // r = d * (1-sa)
186  return (dst.Premultiply() * (1 - src.alpha)).Unpremultiply();
188  // r = s*da + d*(1-sa)
189  return (src.Premultiply() * dst.alpha +
190  dst.Premultiply() * (1 - src.alpha))
191  .Unpremultiply();
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 }

References alpha, BlackTransparent(), impeller::ComponentChoose(), impeller::DoColorBlend(), impeller::DoColorBlendComponents(), impeller::kClear, impeller::kColor, impeller::kColorBurn, impeller::kColorDodge, impeller::kDarken, impeller::kDestination, impeller::kDestinationATop, impeller::kDestinationIn, impeller::kDestinationOut, impeller::kDestinationOver, impeller::kDifference, impeller::kEhCloseEnough, impeller::kExclusion, impeller::kHardLight, impeller::kHue, impeller::kLighten, impeller::kLuminosity, impeller::kModulate, impeller::kMultiply, impeller::kOverlay, impeller::kPlus, impeller::kSaturation, impeller::kScreen, impeller::kSoftLight, impeller::kSource, impeller::kSourceATop, impeller::kSourceIn, impeller::kSourceOut, impeller::kSourceOver, impeller::kXor, impeller::Luminosity(), impeller::Vector3::Max(), impeller::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().

◆ Blue()

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

Definition at line 275 of file color.h.

275 { 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 313 of file color.h.

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

◆ Brown()

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

Definition at line 317 of file color.h.

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

◆ BurlyWood()

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

Definition at line 321 of file color.h.

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

◆ CadetBlue()

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

Definition at line 325 of file color.h.

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

◆ Chartreuse()

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

Definition at line 329 of file color.h.

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

◆ Chocolate()

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

Definition at line 333 of file color.h.

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

◆ Clamp01()

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

Definition at line 235 of file color.h.

235  {
236  return Color(std::clamp(red, 0.0f, 1.0f), std::clamp(green, 0.0f, 1.0f),
237  std::clamp(blue, 0.0f, 1.0f), std::clamp(alpha, 0.0f, 1.0f));
238  }

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

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

◆ Coral()

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

Definition at line 337 of file color.h.

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

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

◆ CornflowerBlue()

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

Definition at line 341 of file color.h.

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

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

◆ Cornsilk()

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

Definition at line 345 of file color.h.

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

◆ Crimson()

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

Definition at line 349 of file color.h.

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

◆ Cyan()

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

Definition at line 353 of file color.h.

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

◆ DarkBlue()

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

Definition at line 357 of file color.h.

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

◆ DarkCyan()

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

Definition at line 361 of file color.h.

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

◆ DarkGoldenrod()

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

Definition at line 365 of file color.h.

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

◆ DarkGray()

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

Definition at line 369 of file color.h.

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

◆ DarkGreen()

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

Definition at line 373 of file color.h.

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

◆ DarkGrey()

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

Definition at line 377 of file color.h.

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

◆ DarkKhaki()

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

Definition at line 381 of file color.h.

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

◆ DarkMagenta()

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

Definition at line 385 of file color.h.

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

◆ DarkOliveGreen()

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

Definition at line 389 of file color.h.

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

◆ DarkOrange()

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

Definition at line 393 of file color.h.

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

◆ DarkOrchid()

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

Definition at line 397 of file color.h.

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

◆ DarkRed()

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

Definition at line 401 of file color.h.

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

◆ DarkSalmon()

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

Definition at line 405 of file color.h.

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

◆ DarkSeagreen()

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

Definition at line 409 of file color.h.

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

◆ DarkSlateBlue()

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

Definition at line 413 of file color.h.

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

◆ DarkSlateGray()

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

Definition at line 417 of file color.h.

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

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

◆ DarkSlateGrey()

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

Definition at line 421 of file color.h.

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

◆ DarkTurquoise()

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

Definition at line 425 of file color.h.

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

◆ DarkViolet()

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

Definition at line 429 of file color.h.

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

◆ DeepPink()

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

Definition at line 433 of file color.h.

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

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

◆ DeepSkyBlue()

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

Definition at line 437 of file color.h.

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

◆ DimGray()

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

Definition at line 441 of file color.h.

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

◆ DimGrey()

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

Definition at line 445 of file color.h.

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

◆ DodgerBlue()

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

Definition at line 449 of file color.h.

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

◆ Firebrick()

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

Definition at line 453 of file color.h.

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

◆ FloralWhite()

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

Definition at line 457 of file color.h.

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

◆ ForestGreen()

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

Definition at line 461 of file color.h.

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

◆ Fuchsia()

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

Definition at line 465 of file color.h.

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

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

◆ Gainsboro()

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

Definition at line 469 of file color.h.

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

◆ Ghostwhite()

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

Definition at line 473 of file color.h.

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

◆ Gold()

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

Definition at line 477 of file color.h.

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

◆ Goldenrod()

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

Definition at line 481 of file color.h.

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

◆ Gray()

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

Definition at line 485 of file color.h.

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

◆ Green()

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

Definition at line 273 of file color.h.

273 { 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 489 of file color.h.

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

◆ Grey()

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

Definition at line 493 of file color.h.

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

◆ Honeydew()

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

Definition at line 497 of file color.h.

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

◆ HotPink()

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

Definition at line 501 of file color.h.

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

◆ IndianRed()

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

Definition at line 505 of file color.h.

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

◆ Indigo()

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

Definition at line 509 of file color.h.

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

◆ IsOpaque()

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

Definition at line 893 of file color.h.

893 { return alpha == 1.0f; }

References alpha.

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

◆ IsTransparent()

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

Definition at line 891 of file color.h.

891 { return alpha == 0.0f; }

References alpha.

◆ Ivory()

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

Definition at line 513 of file color.h.

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

◆ Khaki()

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

Definition at line 517 of file color.h.

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

◆ Lavender()

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

Definition at line 521 of file color.h.

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

◆ LavenderBlush()

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

Definition at line 525 of file color.h.

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

◆ LawnGreen()

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

Definition at line 529 of file color.h.

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

◆ LemonChiffon()

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

Definition at line 533 of file color.h.

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

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

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

References impeller::saturated::b.

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

◆ LightBlue()

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

Definition at line 537 of file color.h.

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

◆ LightCoral()

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

Definition at line 541 of file color.h.

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

◆ LightCyan()

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

Definition at line 545 of file color.h.

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

◆ LightGoldenrodYellow()

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

Definition at line 549 of file color.h.

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

◆ LightGray()

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

Definition at line 553 of file color.h.

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

◆ LightGreen()

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

Definition at line 557 of file color.h.

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

◆ LightGrey()

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

Definition at line 561 of file color.h.

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

◆ LightPink()

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

Definition at line 565 of file color.h.

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

◆ LightSalmon()

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

Definition at line 569 of file color.h.

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

◆ LightSeaGreen()

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

Definition at line 573 of file color.h.

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

◆ LightSkyBlue()

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

Definition at line 577 of file color.h.

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

◆ LightSlateGray()

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

Definition at line 581 of file color.h.

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

◆ LightSlateGrey()

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

Definition at line 585 of file color.h.

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

◆ LightSteelBlue()

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

Definition at line 589 of file color.h.

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

◆ LightYellow()

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

Definition at line 593 of file color.h.

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

◆ Lime()

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

Definition at line 597 of file color.h.

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

◆ LimeGreen()

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

Definition at line 601 of file color.h.

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

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

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

◆ Magenta()

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

Definition at line 609 of file color.h.

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

◆ MakeRGBA8()

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

Definition at line 151 of file color.h.

151  {
152  return Color(
153  static_cast<Scalar>(r) / 255.0f, static_cast<Scalar>(g) / 255.0f,
154  static_cast<Scalar>(b) / 255.0f, static_cast<Scalar>(a) / 255.0f);
155  }

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

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

◆ MediumAquamarine()

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

Definition at line 617 of file color.h.

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

◆ MediumBlue()

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

Definition at line 621 of file color.h.

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

◆ MediumOrchid()

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

Definition at line 625 of file color.h.

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

◆ MediumPurple()

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

Definition at line 629 of file color.h.

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

◆ MediumSeagreen()

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

Definition at line 633 of file color.h.

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

◆ MediumSlateBlue()

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

Definition at line 637 of file color.h.

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

◆ MediumSpringGreen()

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

Definition at line 641 of file color.h.

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

◆ MediumTurquoise()

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

Definition at line 645 of file color.h.

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

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

◆ MediumVioletRed()

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

Definition at line 649 of file color.h.

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

◆ MidnightBlue()

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

Definition at line 653 of file color.h.

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

◆ MintCream()

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

Definition at line 657 of file color.h.

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

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

◆ MistyRose()

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

Definition at line 661 of file color.h.

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

◆ Moccasin()

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

Definition at line 665 of file color.h.

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

◆ NavajoWhite()

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

Definition at line 669 of file color.h.

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

◆ Navy()

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

Definition at line 673 of file color.h.

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

◆ OldLace()

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

Definition at line 677 of file color.h.

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

◆ Olive()

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

Definition at line 681 of file color.h.

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

◆ OliveDrab()

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

Definition at line 685 of file color.h.

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

◆ operator*() [1/2]

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

Definition at line 191 of file color.h.

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

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

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

References alpha, blue, green, and red.

◆ operator+() [1/2]

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

Definition at line 171 of file color.h.

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

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

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

References alpha, blue, green, and red.

◆ operator-() [1/2]

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

Definition at line 181 of file color.h.

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

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

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

References alpha, blue, green, and red.

◆ operator/() [1/2]

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

Definition at line 201 of file color.h.

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

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

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

References alpha, blue, green, and red.

◆ operator==()

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

Definition at line 166 of file color.h.

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

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

◆ Orange()

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

Definition at line 689 of file color.h.

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

◆ OrangeRed()

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

Definition at line 693 of file color.h.

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

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

◆ Orchid()

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

Definition at line 697 of file color.h.

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

◆ PaleGoldenrod()

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

Definition at line 701 of file color.h.

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

◆ PaleGreen()

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

Definition at line 705 of file color.h.

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

◆ PaleTurquoise()

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

Definition at line 709 of file color.h.

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

◆ PaleVioletRed()

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

Definition at line 713 of file color.h.

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

◆ PapayaWhip()

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

Definition at line 717 of file color.h.

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

◆ Peachpuff()

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

Definition at line 721 of file color.h.

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

◆ Peru()

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

Definition at line 725 of file color.h.

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

◆ Pink()

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

Definition at line 729 of file color.h.

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

◆ Plum()

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

Definition at line 733 of file color.h.

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

◆ PowderBlue()

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

Definition at line 737 of file color.h.

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

◆ Premultiply()

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

◆ Purple()

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

Definition at line 741 of file color.h.

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

◆ Random()

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

Definition at line 849 of file color.h.

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

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

◆ Red()

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

Definition at line 271 of file color.h.

271 { 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 745 of file color.h.

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

◆ RoyalBlue()

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

Definition at line 749 of file color.h.

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

◆ SaddleBrown()

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

Definition at line 753 of file color.h.

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

◆ Salmon()

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

Definition at line 757 of file color.h.

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

◆ SandyBrown()

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

Definition at line 761 of file color.h.

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

◆ Seagreen()

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

Definition at line 765 of file color.h.

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

◆ Seashell()

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

Definition at line 769 of file color.h.

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

◆ Sienna()

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

Definition at line 773 of file color.h.

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

◆ Silver()

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

Definition at line 777 of file color.h.

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

◆ SkyBlue()

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

Definition at line 781 of file color.h.

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

◆ SlateBlue()

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

Definition at line 785 of file color.h.

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

◆ SlateGray()

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

Definition at line 789 of file color.h.

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

◆ SlateGrey()

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

Definition at line 793 of file color.h.

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

◆ Snow()

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

Definition at line 797 of file color.h.

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

◆ SpringGreen()

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

Definition at line 801 of file color.h.

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

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

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

◆ Tan()

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

Definition at line 809 of file color.h.

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

◆ Teal()

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

Definition at line 813 of file color.h.

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

◆ Thistle()

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

Definition at line 817 of file color.h.

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

◆ ToARGB()

constexpr uint32_t impeller::Color::ToARGB ( ) const
inlineconstexpr

Convert to ARGB 32 bit color.

Returns
constexpr uint32_t

Definition at line 258 of file color.h.

258  {
259  std::array<uint8_t, 4> result = ToR8G8B8A8();
260  return result[3] << 24 | result[0] << 16 | result[1] << 8 | result[2];
261  }

References ToR8G8B8A8().

Referenced by impeller::testing::CanRenderConicalGradientWithDithering(), impeller::testing::CanRenderRadialGradientWithDithering(), impeller::testing::CanRenderSweepGradientWithDithering(), and impeller::testing::TEST_P().

◆ ToIColor()

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

Convert this color to a 32-bit representation.

Definition at line 158 of file color.h.

158  {
159  return (((std::lround(color.alpha * 255.0f) & 0xff) << 24) |
160  ((std::lround(color.red * 255.0f) & 0xff) << 16) |
161  ((std::lround(color.green * 255.0f) & 0xff) << 8) |
162  ((std::lround(color.blue * 255.0f) & 0xff) << 0)) &
163  0xFFFFFFFF;
164  }

References color.

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

◆ Tomato()

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

Definition at line 821 of file color.h.

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

◆ ToR8G8B8A8()

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

Convert to R8G8B8A8 representation.

Returns
constexpr std::array<u_int8, 4>

Definition at line 245 of file color.h.

245  {
246  uint8_t r = std::round(red * 255.0f);
247  uint8_t g = std::round(green * 255.0f);
248  uint8_t b = std::round(blue * 255.0f);
249  uint8_t a = std::round(alpha * 255.0f);
250  return {r, g, b, a};
251  }

References alpha, impeller::saturated::b, blue, green, and red.

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

◆ Turquoise()

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

Definition at line 825 of file color.h.

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

◆ Unpremultiply()

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

Definition at line 215 of file color.h.

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

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

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

◆ Wheat()

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

Definition at line 833 of file color.h.

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

◆ White()

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

Definition at line 263 of file color.h.

263 { return {1.0f, 1.0f, 1.0f, 1.0f}; }

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

◆ Whitesmoke()

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

Definition at line 837 of file color.h.

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

◆ WhiteTransparent()

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

Definition at line 267 of file color.h.

267 { 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 841 of file color.h.

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

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

◆ YellowGreen()

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

Definition at line 845 of file color.h.

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

Member Data Documentation

◆ alpha

◆ blue

◆ green

◆ red


The documentation for this struct was generated from the following files:
impeller::BlendMode::kDestinationATop
@ kDestinationATop
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Color::Color
constexpr Color()
Definition: color.h:144
impeller::ComponentChoose
static constexpr Vector3 ComponentChoose(Vector3 a, Vector3 b, Vector3 value, Scalar cutoff)
Definition: color.cc:101
impeller::kEhCloseEnough
constexpr float kEhCloseEnough
Definition: constants.h:56
impeller::BlendMode::kLuminosity
@ kLuminosity
impeller::BlendMode::kSource
@ kSource
impeller::BlendMode::kColorDodge
@ kColorDodge
impeller::BlendMode::kDestination
@ kDestination
impeller::BlendMode::kDarken
@ kDarken
impeller::BlendMode::kColor
@ kColor
impeller::Color::alpha
Scalar alpha
Definition: color.h:142
impeller::BlendMode::kDestinationOver
@ kDestinationOver
impeller::BlendMode::kPlus
@ kPlus
impeller::BlendMode::kOverlay
@ kOverlay
impeller::DoColorBlendComponents
static constexpr Color DoColorBlendComponents(Color dst, Color src, const std::function< Scalar(Scalar, Scalar)> &blend_func)
Definition: color.cc:147
impeller::Color::green
Scalar green
Definition: color.h:132
impeller::BlendMode::kModulate
@ kModulate
impeller::Min
static constexpr Color Min(Color c, float threshold)
Definition: color.cc:55
impeller::BlendMode::kSourceOut
@ kSourceOut
impeller::BlendMode::kSaturation
@ kSaturation
impeller::BlendMode::kDifference
@ kDifference
impeller::BlendMode::kLighten
@ kLighten
impeller::BlendMode::kSoftLight
@ kSoftLight
impeller::BlendMode::kColorBurn
@ kColorBurn
impeller::BlendMode::kHardLight
@ kHardLight
impeller::DoColorBlend
static constexpr Color DoColorBlend(Color dst, Color src, const std::function< Vector3(Vector3, Vector3)> &blend_rgb_func)
Definition: color.cc:139
impeller::BlendMode::kClear
@ kClear
impeller::SetSaturation
static constexpr Vector3 SetSaturation(Vector3 color, Scalar saturation)
Definition: color.cc:94
impeller::SetLuminosity
static constexpr Vector3 SetLuminosity(Vector3 color, Scalar luminosity)
Definition: color.cc:83
impeller::Color::ToR8G8B8A8
constexpr std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
Definition: color.h:245
impeller::Color::red
Scalar red
Definition: color.h:127
impeller::Luminosity
static constexpr Scalar Luminosity(Vector3 color)
Definition: color.cc:63
impeller::BlendMode::kDestinationIn
@ kDestinationIn
impeller::BlendMode::kExclusion
@ kExclusion
impeller::BlendMode::kDestinationOut
@ kDestinationOut
impeller::saturated::b
SI b
Definition: saturated_math.h:87
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:269
impeller::BlendMode::kSourceIn
@ kSourceIn
impeller::BlendMode::kScreen
@ kScreen
impeller::ScalarNearlyEqual
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
Definition: scalar.h:35
color
DlColor color
Definition: dl_golden_blur_unittests.cc:24
impeller::BlendMode::kHue
@ kHue
impeller::BlendMode::kXor
@ kXor
impeller::Color::blue
Scalar blue
Definition: color.h:137
impeller::BlendMode::kSourceATop
@ kSourceATop
impeller::BlendMode::kMultiply
@ kMultiply
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::Saturation
static constexpr Scalar Saturation(Vector3 color)
Definition: color.cc:89