SkColor Reference

Color constants can be helpful to write code, documenting the meaning of values the represent transparency and color values. The use of Color constants is not required.

Alpha represents the transparency of Color. Color with Alpha of zero is fully transparent. Color with Alpha of 255 is fully opaque. Some, but not all pixel formats contain Alpha. Pixels with Alpha may store it as unsigned integers or floating point values. Unsigned integer Alpha ranges from zero, fully transparent, to all bits set, fully opaque. Floating point Alpha ranges from zero, fully transparent, to one, fully opaque.


8-bit type for an alpha value. 255 is 100% opaque, zero is 100% transparent.


32-bit ARGB Color value, Unpremultiplied. Color components are always in a known order. This is different from SkPMColor, which has its bytes in a configuration dependent order, to match the format of kBGRA_8888_SkColorType bitmaps. SkColor is the type used to specify colors in SkPaint and in gradients.

Color that is Premultiplied has the same component values as Color that is Unpremultiplied if Alpha is 255, fully opaque, although may have the component values in a different order.

See Also

SkPMColor


Returns Color value from 8-bit component values. Asserts if SK_DEBUG is defined if a, r, g, or b exceed 255. Since Color is Unpremultiplied, a may be smaller than the largest of r, g, and b.

Parameters

Return Value

color and alpha, Unpremultiplied

Example

See Also

SkColorSetRGB SkPaint::setARGB SkPaint::setColor SkColorSetA


Returns Color value from 8-bit component values, with Alpha set fully opaque to 255.

Parameters

Return Value

color with opaque alpha

Example

See Also

SkColorSetARGB


Returns Alpha byte from Color value.

Parameters

Example

See Also

SkPaint::getAlpha


Returns red component of Color, from zero to 255.

Parameters

Return Value

red byte

Example

See Also

SkColorGetG SkColorGetB


Returns green component of Color, from zero to 255.

Parameters

Return Value

green byte

Example

See Also

SkColorGetR SkColorGetB


Returns blue component of Color, from zero to 255.

Parameters

Return Value

blue byte

Example

See Also

SkColorGetR SkColorGetG


Returns Unpremultiplied Color with red, blue, and green set from c; and alpha set from a. Alpha component of c is ignored and is replaced by a in result.

Parameters

Return Value

Color with transparency

Example

See Also

SkColorSetARGB


Alpha constants are conveniences to represent fully transparent and fully opaque colors and masks. Their use is not required.

Constants

Example

Example

See Also

SkAlpha SK_ColorTRANSPARENT SK_ColorBLACK


Color names are provided as conveniences, but are not otherwise special. The values chosen for names may not be the same as values used by SVG, HTML, CSS, or colors named by a platform.

Constants

Example

Example

Example

Example

See Also

SK_ColorTRANSPARENT SkCanvas::clear SK_AlphaOPAQUE

Hue represents an angle, in degrees, on a color wheel. Hue has a positive value modulo 360, where zero degrees is red.

Saturation represents the intensity of the color. Saturation varies from zero, with no Hue contribution; to one, with full Hue contribution.

Value represents the lightness of the color. Value varies from zero, black; to one, full brightness.


Converts RGB to its HSV components. hsv[0] contains HSV_Hue, a value from zero to less than 360. hsv[1] contains HSV_Saturation, a value from zero to one. hsv[2] contains HSV_Value, a value from zero to one.

Parameters

Example

See Also

SkColorToHSV SkHSVToColor


Converts ARGB to its HSV components. Alpha in ARGB is ignored. hsv[0] contains HSV_Hue, and is assigned a value from zero to less than 360. hsv[1] contains HSV_Saturation, a value from zero to one. hsv[2] contains HSV_Value, a value from zero to one.

Parameters

Example

See Also

SkRGBToHSV SkHSVToColor


Converts HSV components to an ARGB color. Alpha is passed through unchanged. hsv[0] represents HSV_Hue, an angle from zero to less than 360. hsv[1] represents HSV_Saturation, and varies from zero to one. hsv[2] represents HSV_Value, and varies from zero to one.

Out of range hsv values are pinned.

Parameters

Return Value

ARGB equivalent to HSV

Example

See Also

SkColorToHSV SkRGBToHSV


Converts HSV components to an ARGB color. Alpha is set to 255. hsv[0] represents HSV_Hue, an angle from zero to less than 360. hsv[1] represents HSV_Saturation, and varies from zero to one. hsv[2] represents HSV_Value, and varies from zero to one.

Out of range hsv values are pinned.

Parameters

Return Value

RGB equivalent to HSV

Example

See Also

SkColorToHSV SkRGBToHSV


32-bit ARGB color value, Premultiplied. The byte order for this value is configuration dependent, matching the format of kBGRA_8888_SkColorType bitmaps. This is different from SkColor, which is Unpremultiplied, and is always in the same byte order.


Returns a SkPMColor value from Unpremultiplied 8-bit component values.

Parameters

Return Value

Premultiplied Color

Example

See Also

SkPreMultiplyColor


Returns PM_Color closest to Color c. Multiplies c RGB components by the c Alpha, and arranges the bytes to match the format of kN32_SkColorType.

Parameters

Return Value

Premultiplied Color

Example

See Also

SkPreMultiplyARGB