Skia
2D Graphics Library
|
Types, consts, functions, and macros for colors. More...
#include "include/core/SkAlphaType.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkCPUTypes.h"
#include <array>
#include <cstdint>
Go to the source code of this file.
Classes | |
struct | SkRGBA4f< kAT > |
RGBA color value, holding four floating point components. More... | |
Namespaces | |
SkColors | |
Macros | |
#define | SkColorSetRGB(r, g, b) SkColorSetARGB(0xFF, r, g, b) |
Returns color value from 8-bit component values, with alpha set fully opaque to 255. More... | |
#define | SkColorGetA(color) (((color) >> 24) & 0xFF) |
Returns alpha byte from color value. More... | |
#define | SkColorGetR(color) (((color) >> 16) & 0xFF) |
Returns red component of color, from zero to 255. More... | |
#define | SkColorGetG(color) (((color) >> 8) & 0xFF) |
Returns green component of color, from zero to 255. More... | |
#define | SkColorGetB(color) (((color) >> 0) & 0xFF) |
Returns blue component of color, from zero to 255. More... | |
Typedefs | |
typedef uint8_t | SkAlpha |
8-bit type for an alpha value. More... | |
typedef uint32_t | SkColor |
32-bit ARGB color value, unpremultiplied. More... | |
typedef uint32_t | SkPMColor |
32-bit ARGB color value, premultiplied. More... | |
using | SkColor4f = SkRGBA4f< kUnpremul_SkAlphaType > |
Enumerations | |
enum class | SkColorChannel { kR , kG , kB , kA , kLastEnum = kA } |
Describes different color channels one can manipulate. More... | |
enum | SkColorChannelFlag : uint32_t { kRed_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kR) , kGreen_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kG) , kBlue_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kB) , kAlpha_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kA) , kGray_SkColorChannelFlag = 0x10 , kGrayAlpha_SkColorChannelFlags = kGray_SkColorChannelFlag | kAlpha_SkColorChannelFlag , kRG_SkColorChannelFlags = kRed_SkColorChannelFlag | kGreen_SkColorChannelFlag , kRGB_SkColorChannelFlags = kRG_SkColorChannelFlags | kBlue_SkColorChannelFlag , kRGBA_SkColorChannelFlags = kRGB_SkColorChannelFlags | kAlpha_SkColorChannelFlag } |
Used to represent the channels available in a color type or texture format as a mask. More... | |
Functions | |
static constexpr SkColor | SkColorSetARGB (U8CPU a, U8CPU r, U8CPU g, U8CPU b) |
Returns color value from 8-bit component values. More... | |
static constexpr SkColor | SkColorSetA (SkColor c, U8CPU a) |
Returns unpremultiplied color with red, blue, and green set from c; and alpha set from a. More... | |
SK_API void | SkRGBToHSV (U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3]) |
Converts RGB to its HSV components. More... | |
static void | SkColorToHSV (SkColor color, SkScalar hsv[3]) |
Converts ARGB to its HSV components. More... | |
SK_API SkColor | SkHSVToColor (U8CPU alpha, const SkScalar hsv[3]) |
Converts HSV components to an ARGB color. More... | |
static SkColor | SkHSVToColor (const SkScalar hsv[3]) |
Converts HSV components to an ARGB color. More... | |
SK_API SkPMColor | SkPreMultiplyARGB (U8CPU a, U8CPU r, U8CPU g, U8CPU b) |
Returns a SkPMColor value from unpremultiplied 8-bit component values. More... | |
SK_API SkPMColor | SkPreMultiplyColor (SkColor c) |
Returns pmcolor closest to color c. More... | |
Variables | |
constexpr SkAlpha | SK_AlphaTRANSPARENT = 0x00 |
Represents fully transparent SkAlpha value. More... | |
constexpr SkAlpha | SK_AlphaOPAQUE = 0xFF |
Represents fully opaque SkAlpha value. More... | |
constexpr SkColor | SK_ColorTRANSPARENT = SkColorSetARGB(0x00, 0x00, 0x00, 0x00) |
Represents fully transparent SkColor. More... | |
constexpr SkColor | SK_ColorBLACK = SkColorSetARGB(0xFF, 0x00, 0x00, 0x00) |
Represents fully opaque black. More... | |
constexpr SkColor | SK_ColorDKGRAY = SkColorSetARGB(0xFF, 0x44, 0x44, 0x44) |
Represents fully opaque dark gray. More... | |
constexpr SkColor | SK_ColorGRAY = SkColorSetARGB(0xFF, 0x88, 0x88, 0x88) |
Represents fully opaque gray. More... | |
constexpr SkColor | SK_ColorLTGRAY = SkColorSetARGB(0xFF, 0xCC, 0xCC, 0xCC) |
Represents fully opaque light gray. More... | |
constexpr SkColor | SK_ColorWHITE = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF) |
Represents fully opaque white. More... | |
constexpr SkColor | SK_ColorRED = SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00) |
Represents fully opaque red. More... | |
constexpr SkColor | SK_ColorGREEN = SkColorSetARGB(0xFF, 0x00, 0xFF, 0x00) |
Represents fully opaque green. More... | |
constexpr SkColor | SK_ColorBLUE = SkColorSetARGB(0xFF, 0x00, 0x00, 0xFF) |
Represents fully opaque blue. More... | |
constexpr SkColor | SK_ColorYELLOW = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0x00) |
Represents fully opaque yellow. More... | |
constexpr SkColor | SK_ColorCYAN = SkColorSetARGB(0xFF, 0x00, 0xFF, 0xFF) |
Represents fully opaque cyan. More... | |
constexpr SkColor | SK_ColorMAGENTA = SkColorSetARGB(0xFF, 0xFF, 0x00, 0xFF) |
Represents fully opaque magenta. More... | |
constexpr SkColor4f | SkColors::kTransparent = {0, 0, 0, 0} |
constexpr SkColor4f | SkColors::kBlack = {0, 0, 0, 1} |
constexpr SkColor4f | SkColors::kDkGray = {0.25f, 0.25f, 0.25f, 1} |
constexpr SkColor4f | SkColors::kGray = {0.50f, 0.50f, 0.50f, 1} |
constexpr SkColor4f | SkColors::kLtGray = {0.75f, 0.75f, 0.75f, 1} |
constexpr SkColor4f | SkColors::kWhite = {1, 1, 1, 1} |
constexpr SkColor4f | SkColors::kRed = {1, 0, 0, 1} |
constexpr SkColor4f | SkColors::kGreen = {0, 1, 0, 1} |
constexpr SkColor4f | SkColors::kBlue = {0, 0, 1, 1} |
constexpr SkColor4f | SkColors::kYellow = {1, 1, 0, 1} |
constexpr SkColor4f | SkColors::kCyan = {0, 1, 1, 1} |
constexpr SkColor4f | SkColors::kMagenta = {1, 0, 1, 1} |
Types, consts, functions, and macros for colors.
#define SkColorGetA | ( | color | ) | (((color) >> 24) & 0xFF) |
Returns alpha byte from color value.
#define SkColorGetB | ( | color | ) | (((color) >> 0) & 0xFF) |
Returns blue component of color, from zero to 255.
#define SkColorGetG | ( | color | ) | (((color) >> 8) & 0xFF) |
Returns green component of color, from zero to 255.
#define SkColorGetR | ( | color | ) | (((color) >> 16) & 0xFF) |
Returns red component of color, from zero to 255.
#define SkColorSetRGB | ( | r, | |
g, | |||
b | |||
) | SkColorSetARGB(0xFF, r, g, b) |
Returns color value from 8-bit component values, with alpha set fully opaque to 255.
typedef uint8_t SkAlpha |
8-bit type for an alpha value.
255 is 100% opaque, zero is 100% transparent.
typedef uint32_t SkColor |
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.
using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType> |
typedef uint32_t SkPMColor |
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.
|
strong |
enum SkColorChannelFlag : uint32_t |
Used to represent the channels available in a color type or texture format as a mask.
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.
c | packed RGB, eight bits per component |
a | alpha: transparent at zero, fully opaque at 255 |
|
inlinestaticconstexpr |
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.
a | amount of alpha, from fully transparent (0) to fully opaque (255) |
r | amount of red, from no red (0) to full red (255) |
g | amount of green, from no green (0) to full green (255) |
b | amount of blue, from no blue (0) to full blue (255) |
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.
color | ARGB color to convert |
hsv | three element array which holds the resulting HSV components |
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.
hsv | three element array which holds the input HSV components |
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.
alpha | alpha component of the returned ARGB color |
hsv | three element array which holds the input HSV components |
SK_API SkPMColor SkPreMultiplyARGB | ( | U8CPU | a, |
U8CPU | r, | ||
U8CPU | g, | ||
U8CPU | b | ||
) |
Returns a SkPMColor value from unpremultiplied 8-bit component values.
a | amount of alpha, from fully transparent (0) to fully opaque (255) |
r | amount of red, from no red (0) to full red (255) |
g | amount of green, from no green (0) to full green (255) |
b | amount of blue, from no blue (0) to full blue (255) |
Returns pmcolor closest to color c.
Multiplies c RGB components by the c alpha, and arranges the bytes to match the format of kN32_SkColorType.
c | unpremultiplied ARGB color |
SK_API void SkRGBToHSV | ( | U8CPU | red, |
U8CPU | green, | ||
U8CPU | blue, | ||
SkScalar | hsv[3] | ||
) |
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.
red | red component value from zero to 255 |
green | green component value from zero to 255 |
blue | blue component value from zero to 255 |
hsv | three element array which holds the resulting HSV components |
|
constexpr |
Represents fully opaque SkAlpha value.
SkAlpha ranges from zero, fully transparent; to 255, fully opaque.
|
constexpr |
Represents fully transparent SkAlpha value.
SkAlpha ranges from zero, fully transparent; to 255, fully opaque.
|
constexpr |
Represents fully opaque black.
|
constexpr |
Represents fully opaque blue.
|
constexpr |
Represents fully opaque cyan.
HTML aqua is equivalent.
|
constexpr |
Represents fully opaque dark gray.
Note that SVG dark gray is equivalent to 0xFFA9A9A9.
|
constexpr |
Represents fully opaque gray.
Note that HTML gray is equivalent to 0xFF808080.
|
constexpr |
Represents fully opaque green.
HTML lime is equivalent. Note that HTML green is equivalent to 0xFF008000.
|
constexpr |
Represents fully opaque light gray.
HTML silver is equivalent to 0xFFC0C0C0. Note that SVG light gray is equivalent to 0xFFD3D3D3.
|
constexpr |
Represents fully opaque magenta.
HTML fuchsia is equivalent.
|
constexpr |
Represents fully opaque red.
|
constexpr |
Represents fully transparent SkColor.
May be used to initialize a destination containing a mask or a non-rectangular image.
|
constexpr |
Represents fully opaque white.
|
constexpr |
Represents fully opaque yellow.