Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkColor.h File Reference

Types and macros for colors. More...

#include "SkScalar.h"
#include "SkPoint3.h"
#include "SkTypes.h"

Go to the source code of this file.

Classes

struct  SkColor4f
 

Macros

#define SkColorSetARGBMacro(a, r, g, b)
 
#define SkColorSetARGB(a, r, g, b)   SkColorSetARGBInline(a, r, g, b)
 gcc will generate static initializers for code of this form: static const SkColor kMyColor = SkColorSetARGB(0xFF, 0x01, 0x02, 0x03) if SkColorSetARGB() is a static inline, but not if it's a macro.
 
#define SkColorSetRGB(r, g, b)   SkColorSetARGB(0xFF, r, g, b)
 Return a SkColor value from 8 bit component values, with an implied value of 0xFF for alpha (fully opaque)
 
#define SkColorGetA(color)   (((color) >> 24) & 0xFF)
 return the alpha byte from a SkColor value
 
#define SkColorGetR(color)   (((color) >> 16) & 0xFF)
 return the red byte from a SkColor value
 
#define SkColorGetG(color)   (((color) >> 8) & 0xFF)
 return the green byte from a SkColor value
 
#define SkColorGetB(color)   (((color) >> 0) & 0xFF)
 return the blue byte from a SkColor value
 
#define SK_AlphaTRANSPARENT   static_cast<SkAlpha>(0x00)
 transparent SkAlpha value
 
#define SK_AlphaOPAQUE   static_cast<SkAlpha>(0xFF)
 opaque SkAlpha value
 
#define SK_ColorTRANSPARENT   static_cast<SkColor>(0x00000000)
 transparent SkColor value
 
#define SK_ColorBLACK   static_cast<SkColor>(0xFF000000)
 black SkColor value
 
#define SK_ColorDKGRAY   static_cast<SkColor>(0xFF444444)
 dark gray SkColor value
 
#define SK_ColorGRAY   static_cast<SkColor>(0xFF888888)
 gray SkColor value
 
#define SK_ColorLTGRAY   static_cast<SkColor>(0xFFCCCCCC)
 light gray SkColor value
 
#define SK_ColorWHITE   static_cast<SkColor>(0xFFFFFFFF)
 white SkColor value
 
#define SK_ColorRED   static_cast<SkColor>(0xFFFF0000)
 red SkColor value
 
#define SK_ColorGREEN   static_cast<SkColor>(0xFF00FF00)
 green SkColor value
 
#define SK_ColorBLUE   static_cast<SkColor>(0xFF0000FF)
 blue SkColor value
 
#define SK_ColorYELLOW   static_cast<SkColor>(0xFFFFFF00)
 yellow SkColor value
 
#define SK_ColorCYAN   static_cast<SkColor>(0xFF00FFFF)
 cyan SkColor value
 
#define SK_ColorMAGENTA   static_cast<SkColor>(0xFFFF00FF)
 magenta SkColor value
 

Typedefs

typedef uint8_t SkAlpha
 8-bit type for an alpha value. More...
 
typedef uint32_t SkColor
 32 bit ARGB color value, not premultiplied. More...
 
typedef uint32_t SkPMColor
 32 bit ARGB color value, premultiplied. More...
 

Functions

static SkColor SkColorSetARGBInline (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 Return a SkColor value from 8 bit component values.
 
static constexpr SkColor SkColorSetA (SkColor c, U8CPU a)
 
SK_API void SkRGBToHSV (U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3])
 Convert RGB components to HSV. More...
 
static void SkColorToHSV (SkColor color, SkScalar hsv[3])
 Convert the argb color to its HSV components. More...
 
SK_API SkColor SkHSVToColor (U8CPU alpha, const SkScalar hsv[3])
 Convert HSV components to an ARGB color. More...
 
static SkColor SkHSVToColor (const SkScalar hsv[3])
 Convert HSV components to an ARGB color. More...
 
SK_API SkPMColor SkPreMultiplyARGB (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 Return a SkPMColor value from unpremultiplied 8 bit component values.
 
SK_API SkPMColor SkPreMultiplyColor (SkColor c)
 Return a SkPMColor value from a SkColor value. More...
 

Detailed Description

Types and macros for colors.

Macro Definition Documentation

#define SkColorSetARGBMacro (   a,
  r,
  g,
 
)
Value:
static_cast<SkColor>( \
(static_cast<U8CPU>(a) << 24) | \
(static_cast<U8CPU>(r) << 16) | \
(static_cast<U8CPU>(g) << 8) | \
(static_cast<U8CPU>(b) << 0))
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
unsigned U8CPU
Fast type for unsigned 8 bits.
Definition: SkTypes.h:191

Typedef Documentation

typedef uint8_t SkAlpha

8-bit type for an alpha value.

0xFF is 100% opaque, 0x00 is 100% transparent.

typedef uint32_t SkColor

32 bit ARGB color value, not premultiplied.

The 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 kARGB32 bitmaps. SkColor is the type used to specify colors in SkPaint and in gradients.

typedef uint32_t SkPMColor

32 bit ARGB color value, premultiplied.

The byte order for this value is configuration dependent, matching the format of kARGB32 bitmaps. This is different from SkColor, which is nonpremultiplied, and is always in the same byte order.

Function Documentation

static void SkColorToHSV ( SkColor  color,
SkScalar  hsv[3] 
)
inlinestatic

Convert the argb color to its HSV components.

hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]

Parameters
colorthe argb color to convert. Note: the alpha component is ignored.
hsv3 element array which holds the resulting HSV components.
SK_API SkColor SkHSVToColor ( U8CPU  alpha,
const SkScalar  hsv[3] 
)

Convert HSV components to an ARGB color.

The alpha component is passed through unchanged. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.

Parameters
alphathe alpha component of the returned argb color.
hsv3 element array which holds the input HSV components.
Returns
the resulting argb color
static SkColor SkHSVToColor ( const SkScalar  hsv[3])
inlinestatic

Convert HSV components to an ARGB color.

The alpha component set to 0xFF. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.

Parameters
hsv3 element array which holds the input HSV components.
Returns
the resulting argb color
SK_API SkPMColor SkPreMultiplyColor ( SkColor  c)

Return a SkPMColor value from a SkColor value.

This is done by multiplying the color components by the color's alpha, and by arranging the bytes in a configuration dependent order, to match the format of kARGB32 bitmaps.

SK_API void SkRGBToHSV ( U8CPU  red,
U8CPU  green,
U8CPU  blue,
SkScalar  hsv[3] 
)

Convert RGB components to HSV.

hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]

Parameters
redred component value [0..255]
greengreen component value [0..255]
blueblue component value [0..255]
hsv3 element array which holds the resulting HSV components.