SkColor4f Reference



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.


Compares SkRGBA4f with other, and returns true if all components are equivalent.

Parameters

Return Value

true if SkRGBA4f equals other

Example

Example Output

colorRed == colorNamedRed

See Also

operator!=(const SkRGBA4f& other) const


Compares SkRGBA4f with other, and returns true if all components are not equivalent.

Parameters

Return Value

true if SkRGBA4f is not equal to other

Example

Example Output

colorGray != colorNamedGray

See Also

operator==(const SkRGBA4f& other) const


Multiplies each component by scale. Does not pin the result.

Parameters

Return Value

scaled color

See Also

SkBlendMode::kMultiply


Multiplies each component by scale component. Does not pin the result.

Parameters

Return Value

scaled color

See Also

SkBlendMode::kMultiply


Returns SkRGBA4f components as a read-only array.

Return Value

components as read-only array

Example

Example Output

red=0.266667 green=0.533333 blue=0.8 alpha=0.533333
[0]=0.266667 [1]=0.533333 [2]=0.8 [3]=0.533333

See Also

SkColor4f


Returns SkRGBA4f components as a writable array.

Return Value

components as writable array

Example

Example Output

red=0.266667 green=0.533333 blue=0.8 alpha=0.533333
[0]=0.266667 [1]=0.533333 [2]=0.8 [3]=1

See Also

SkColor4f


Returns SkRGBA4f component by index, zero through three. index out of range triggers an assert in debug builds.

Parameters

Return Value

component by index

See Also

vec


Returns writable component reference by index, zero through three. index out of range triggers an assert in debug builds.

Parameters

Return Value

writable component reference by index

See Also

vec


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.

Return Value

true if Alpha is one

See Also

vec SkColorGetA


Returns closest SkRGBA4f to SkColor. Only allowed if SkRGBA4f is unpremultiplied.

Parameters

Return Value

SkColor as SkRGBA4f

Example

Example Output

red=0.301961 green=0.396078 blue=0.6 alpha=0.168627
red=77 green=101 blue=153 alpha=43

See Also

toSkColor


Converts to closest SkColor.

Return Value

closest Color

Example

Example Output

red=18 green=33 blue=82 alpha=43
red=0.0705882 green=0.129412 blue=0.321569 alpha=0.168627

See Also

FromColor


Converts from Premultiplied integer components to Unpremultiplied float components.

Parameters

Return Value

Unpremultiplied color

See Also

FromColor


Returns SkColor4f with all components premultiplied by Alpha.

Return Value

Premultiplied color

See Also

unpremul


Returns SkRGBA4f with all components independent of Alpha.

Return Value

Unpremultiplied color

See Also

premul


Produces bytes in RGBA order. Component values are not affected by color Alpha.

Return Value

color


Returns from color kRGBA_8888_SkColorType order. Component values are not affected by color Alpha.

Parameters

Return Value

color


Returns color with Alpha set to one.

Return Value

color