SkColor4f Reference

Color4f

Struct SkColor4f

Member

SkColor4f members may be read and written directly without using a member function.

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.

Each component is independent of the others; fA Alpha is not Premultiplied with fG green, fB blue, or fR red.

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.

Overview

Operator

SkColor4f operators inline class member functions with arithmetic equivalents.

Member Function

SkColor4f member functions read and modify the structure properties.

Members

operator==

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

Parameters

Return Value

true if Color4f equals other

Example

Example Output

colorRed == colorNamedRed

See Also

operator!=(const SkColor4f& other) const


operator!=

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

Parameters

Return Value

true if Color4f is not equal to other

Example

Example Output

colorGray != colorNamedGray

See Also

operator==(const SkColor4f& other) const


vec

Returns Color4f 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 Color4f 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


Pin

Constructs and returns Color4f with each component pinned from zero to one.

Parameters

Return Value

Color4f with valid components

Example

See Also

pin FromColor


FromColor

Converts to closest Color4f.

Parameters

Return Value

Color4f equivalent

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


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


pin

Returns Color4f with all components in the range from zero to one.

Return Value

Color4f with valid components

Example

See Also

Pin


premul

Returns SkColor4f with all components premultiplied by Alpha.

Return Value

Premultiplied color

See Also

unpremul


unpremul

Returns SkColor4f with all components independent of Alpha.

Return Value

Unpremultiplied color

See Also

premul


toPM4f

Return Value

premultiplied color


Struct SkPM4f