struct SkRGBA4f { float fR; float fG; float fB; float fA; bool operator==(const SkRGBA4f& other) const; bool operator!=(const SkRGBA4f& other) const; SkRGBA4f operator*(float scale) const; SkRGBA4f operator*(const SkRGBA4f& scale) const; const float* vec() const; float* vec(); float operator[](int index) const; float& operator[](int index); bool isOpaque() const; static SkRGBA4f FromColor(SkColor color); SkColor toSkColor() const; static SkRGBA4f FromPMColor(SkPMColor); SkRGBA4f<kPremul_SkAlphaType> premul() const; SkRGBA4f<kUnpremul_SkAlphaType> unpremul() const; uint32_t toBytes_RGBA() const; static SkRGBA4f FromBytes_RGBA(uint32_t color); SkRGBA4f makeOpaque() const; };
Each component is stored as a 32-bit single precision floating point float value. All values are allowed, but only the range from zero to one is meaningful.
Components are independent of the others if defined with kUnpremul_SkAlphaType; fA Alpha is may be greater or smaller than fG green, fB blue, or fR red. SkColor4f is shorthand for Unpremultiplied SkRGBA4f.
Components are connected if defined with kPremul_SkAlphaType; fA Alpha is equal to or larger than fG green, fB blue, and fR red. The values stored in fG, fB, and fR combine the color component with the Alpha component.
Values smaller than zero or larger than one are allowed. Values out of range may be used with Blend_Mode so that the final component is in range.
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>float</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkRGBA4f_fR'><code>fR</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
Single precision float for red ranges from no red (0.0) to full red (1.0).
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>float</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkRGBA4f_fG'><code>fG</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
Single precision float for green ranges from no green (0.0) to full green (1.0).
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>float</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkRGBA4f_fB'><code>fB</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
Single precision float for blue ranges from no blue (0.0) to full blue (1.0).
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>float</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkRGBA4f_fA'><code>fA</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
Single precision float for Alpha ranges from no Alpha (0.0) to full Alpha (1.0).
bool operator==(const SkRGBA4f& other)const
Compares SkRGBA4f with other, and returns true if all components are equivalent.
other |
SkRGBA4f to compare |
operator!=(const SkRGBA4f& other) const
bool operator!=(const SkRGBA4f& other)const
Compares SkRGBA4f with other, and returns true if all components are not equivalent.
other |
SkRGBA4f to compare |
true if SkRGBA4f is not equal to other
operator==(const SkRGBA4f& other) const
SkRGBA4f operator*(float scale)const
Multiplies each component by scale. Does not pin the result.
scale |
component multiplier |
scaled color
SkRGBA4f operator*(const SkRGBA4f& scale)const
Multiplies each component by scale component. Does not pin the result.
scale |
SkRGBA4f component multipliers |
scaled color
const float* vec()const
Returns SkRGBA4f components as a read-only array.
components as read-only array
float* vec()
Returns SkRGBA4f components as a writable array.
components as writable array
float operator[](int index)const
Returns SkRGBA4f component by index, zero through three. index out of range triggers an assert in debug builds.
index |
component, zero through three |
component by index
float& operator[](int index)
Returns writable component reference by index, zero through three. index out of range triggers an assert in debug builds.
index |
component, zero through three |
writable component reference by index
bool isOpaque()const
Returns true if Alpha component is one. Color has no transparency regardless of whether color is Premultiplied or Unpremultiplied. Triggers a debugging assert if Alpha not valid.
true if Alpha is one
static SkRGBA4f FromColor(SkColor color)
Returns closest SkRGBA4f to SkColor. Only allowed if SkRGBA4f is unpremultiplied.
color |
Color with Alpha, red, blue, and green components |
SkColor toSkColor()const
Converts to closest SkColor.
closest Color
static SkRGBA4f FromPMColor(SkPMColor)
Converts from Premultiplied integer components to Unpremultiplied float components.
SkPMColor |
Premultiplied color |
SkRGBA4f<kPremul_SkAlphaType> premul()const
Returns SkColor4f with all components premultiplied by Alpha.
SkRGBA4f<kUnpremul_SkAlphaType> unpremul()const
Returns SkRGBA4f with all components independent of Alpha.
uint32_t toBytes_RGBA()const
Produces bytes in RGBA order. Component values are not affected by color Alpha.
static SkRGBA4f FromBytes_RGBA(uint32_t color)
Returns from color kRGBA_8888_SkColorType order. Component values are not affected by color Alpha.
color |
Premultiplied or Unpremultiplied |
SkRGBA4f makeOpaque()const
Returns color with Alpha set to one.
using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType>;