This class describes a color. More...
Debugging | |
static const SBDTypeColor | black |
The black color. | |
static const SBDTypeColor | white |
The white color. | |
static const SBDTypeColor | red |
The red color. | |
static const SBDTypeColor | green |
The green color. | |
static const SBDTypeColor | blue |
The blue color. | |
static const SBDTypeColor | cyan |
The cyan color. | |
static const SBDTypeColor | magenta |
The magenta color. | |
static const SBDTypeColor | yellow |
The yellow color. | |
static const SBDTypeColor | orange |
The orange color. | |
static const SBDTypeColor | globalXAxis |
The global X axis color. | |
static const SBDTypeColor | globalYAxis |
The global Y axis color. | |
static const SBDTypeColor | globalZAxis |
The global Z axis color. | |
static const SBDTypeColor | localXAxis |
The local X axis color. | |
static const SBDTypeColor | localYAxis |
The local Y axis color. | |
static const SBDTypeColor | localZAxis |
The local Z axis color. | |
static const SBDTypeColor | defaultKeyframeColor |
The default keyframe color. | |
SBDTypeColorData * | dataPointer |
virtual void | print (unsigned int offset=0) const |
Prints the color. | |
SB_DECLARE_DATA (SBDTypeColor) | |
Constructors and destructors | |
SBDTypeColor () | |
Constructs a color (1.0f, 1.0f, 1.0f, 1.0f) | |
SBDTypeColor (float red, float green, float blue, float alpha=1.0f) | |
Constructs a color (red, green, blue, alpha) | |
SBDTypeColor (int red, int green, int blue, int alpha=255) | |
Constructs a color (red, green, blue, alpha) | |
SBDTypeColor (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255) | |
Constructs a color (red, green, blue, alpha) | |
SBDTypeColor (float *color) | |
Constructs a color (color[0], color[1], color[2], color[3]) | |
SBDTypeColor (const SBDTypeColor &color) | |
Copy constructor. | |
SBDTypeColor (SBDTypeColor &&color) noexcept | |
Move constructor. | |
virtual | ~SBDTypeColor () |
Destructs the color. | |
Serialization | |
bool | isSerializable () const |
Returns true. | |
void | serialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) const |
Serializes the color. | |
void | unserialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) |
Unserializes the color. | |
Operators | |
SBDTypeColor & | operator= (const SBDTypeColor &color) |
Copy assignment. | |
SBDTypeColor & | operator= (SBDTypeColor &&color) noexcept |
Move assignment. | |
float & | operator[] (int index) |
Returns a reference to component index . | |
const float & | operator[] (int index) const |
Returns a reference to component index (const version) | |
bool | operator== (const SBDTypeColor &color) const |
bool | operator!= (const SBDTypeColor &color) const |
Accessors | |
float | getRed () const |
int | getRedInt () const |
Returns the red component, the value is in the [0.0, 1.0] interval. | |
void | setRed (int red) |
Returns the red component, the value is in the [0, 255] interval. | |
void | setRed (float red) |
Sets the red component, the value should be in the [0, 255] interval. | |
float | getGreen () const |
Sets the red component, the value should be in the [0.0, 1.0] interval. | |
int | getGreenInt () const |
Returns the green component, the value is in the [0.0, 1.0] interval. | |
void | setGreen (int green) |
Returns the green component, the value is in the [0, 255] interval. | |
void | setGreen (float green) |
Sets the green component, the value should be in the [0, 255] interval. | |
float | getBlue () const |
Sets the green component, the value should be in the [0.0, 1.0] interval. | |
int | getBlueInt () const |
Returns the blue component, the value is in the [0.0, 1.0] interval. | |
void | setBlue (int blue) |
Returns the blue component, the value is in the [0, 255] interval. | |
void | setBlue (float blue) |
Sets the blue component, the value should be in the [0, 255] interval. | |
float | getAlpha () const |
Sets the blue component, the value should be in the [0.0, 1.0] interval. | |
int | getAlphaInt () const |
Returns the alpha component, the value is in the [0.0, 1.0] interval. | |
void | setAlpha (int alpha) |
Returns the alpha component, the value is in the [0, 255] interval. | |
void | setAlpha (float alpha) |
Sets the alpha component, the value should be in the [0, 255] interval. | |
const float * | getColor () const |
Sets the alpha component, the value should be in the [0.0, 1.0] interval. | |
void | getColor (float *color) const |
Stores the four components as a float array. | |
Color conversions | |
static SBDTypeColor | fromHSV (float hue, float saturation, float value) |
Creates a color from a given HSV color. | |
static SBDTypeColor | fromHCL (float hue, float chroma, float luminance) |
Creates a color from a given HCL (CIE LCh_uv) color. | |
static void | toHSV (float *hsv, float *color) |
Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value) | |
static void | fromHSV (float *color, float *hsv) |
Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor) | |
static void | HSVfromSRGB (float *hsv, float *rgb) |
Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value) | |
static void | SRGBfromHSV (float *rgb, float *hsv) |
Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor) | |
static void | toHCL (float *hcl, float *color) |
Converts sRGB color (as in SBColor) to HCL (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) | |
static void | fromHCL (float *color, float *hcl) |
Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to sRGB color (as in SBColor) | |
static void | HCLfromSRGB (float *hcl, float *rgb) |
Converts standard RGB (sRGB) color to HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) | |
static void | SRGBfromHCL (float *rgb, float *hcl) |
Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to standard RGB (sRGB) color. | |
static void | SRGBfromRGB (float *srgb, float *rgb) |
Converts linear RGB values to standard RGB (sRGB) values. | |
static void | RGBfromSRGB (float *rgb, float *srgb) |
Converts standard RGB (sRGB) values to linear RGB values. | |
static void | CIEXYZfromRGB (float *XYZ, float *rgb) |
Converts linear RGB to CIE XYZ with D65/2° standard illuminant. | |
static void | RGBfromCIEXYZ (float *rgb, float *XYZ) |
Converts CIE XYZ with D65/2° standard illuminant to linear RGB. | |
static void | CIEXYZfromSRGB (float *XYZ, float *rgb) |
Converts device independent standard RGB (sRGB) to CIE XYZ with D65/2° standard illuminant. | |
static void | SRGBfromCIEXYZ (float *rgb, float *XYZ) |
Converts CIEXYZ with D65/2° standard illuminant to device independent standard RGB (sRGB) | |
static void | SRGBfromCIELab (float *rgb, float *lab) |
Converts color from CIE L*a*b* color space to standard RGB (sRGB) color space. | |
static void | CIELabfromSRGB (float *lab, float *rgb) |
Converts color from standard RGB (sRGB) color space to CIE L*a*b* color space. | |
static void | CIEXYZfromCIELab (float *XYZ, float *lab) |
Converts CIE L*a*b* to CIE XYZ D65/2° | |
static void | CIELabfromCIEXYZ (float *lab, float *XYZ) |
Converts CIE XYZ D65/2° to CIE L*a*b*. | |
static void | CIEXYZfromCIELuv (float *XYZ, float *luv) |
Converts CIE L*u*v* to CIE XYZ D65/2° | |
static void | CIELuvfromCIEXYZ (float *luv, float *XYZ) |
Converts CIE XYZ D65/2° to CIE L*u*v*. | |
static void | CIEuvfromCIEXYZ (float *uv, float *XYZ) |
Converts CIE XYZ D65/2° to u and v coordinates for the CIE Luv. | |
static void | cylindricalCIELabfromCIELab (float *hcl, float *lab) |
Converts CIE L*a*b* to CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) | |
static void | CIELabfromCylindricalCIELab (float *lab, float *hcl) |
Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to CIE L*a*b*. | |
static void | cylindricalCIELuvfromCIELuv (float *hcl, float *luv) |
Converts CIE L*u*v* to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) | |
static void | CIELuvfromCylindricalCIELuv (float *luv, float *hcl) |
Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to CIE L*u*v*. | |
static void | cylindricalCIELabfromSRGB (float *hcl, float *rgb) |
Converts standard RGB (sRGB) to CIE L*a*b* in cylindrical coordinates a.k.a. (CIE LCh_ab) | |
static void | SRGBfromCylindricalCIELab (float *rgb, float *hcl) |
Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to standard RGB (sRGB) | |
static void | cylindricalCIELuvfromSRGB (float *hcl, float *rgb) |
Converts standard RGB (sRGB) to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) | |
static void | SRGBfromCylindricalCIELuv (float *rgb, float *hcl) |
Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to standard RGB (sRGB) | |
This class describes a color in SAMSON. Please refer to this page for more information.
SBColor uses the standard RGB (sRGB).
This class also provides static functions to transform colors between different color spaces:
To use color conversion function, pass two pointers to float arrays (with 3 values) in a function: the first one will contain the result, the second one contains the input color data.
Example:
Note: The conversions might not always be exact. For example, a converstion from sRGB to HCL and then back from HCL to sRGB might result in values that might slightly differ from the original ones by some numerical error due to approximations in conversion functions and floating-point arithmetics.
|
static |
SBDTypeColor::CIELabfromCIEXYZ - Converts CIE XYZ D65/2° to CIE L*a*b*.
lab | - CIE L*a*b* coordinates |
XYZ | - X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883) |
|
static |
SBDTypeColor::CIELabfromCylindricalCIELab - Converts CIE L*a*b* in cylindrical coordinates (CIE LCh_ab) to CIE L*a*b*.
lab | - L*a*b* coordinates in the CIE L*a*b* |
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Lab: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
|
static |
SBDTypeColor::CIELabfromSRGB - Converts standard RGB (sRGB) to CIE L*a*b*.
lab | - L*a*b* coordinates in the CIE L*a*b* color space |
rgb | - standard RGB (sRGB) |
|
static |
SBDTypeColor::CIELuvfromCIEXYZ - Converts CIE XYZ D65/2° to CIE L*u*v*.
luv | - Resulting L*u*v* coordinates in the CIE L*u*v* color space. |
XYZ | - X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883). |
|
static |
SBDTypeColor::CIELuvfromCylindricalCIELuv - Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to CIE L*u*v*.
luv | - L*u*v* coordinates in the CIE L*u*v* |
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
|
static |
SBDTypeColor::CIEuvfromCIEXYZ - An auxiliary function that computes u and v coordinates for the CIE Luv from CIE XYZ.
uv | - u and v values |
XYZ | - X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883). |
|
static |
SBDTypeColor::CIEXYZfromCIELab - Converts CIE L*a*b* to CIE XYZ D65/2°
XYZ | - X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883). |
lab | - L*a*b* coordinates in the CIE L*a*b* color space |
|
static |
SBDTypeColor::CIEXYZfromCIELuv - Converts CIE L*u*v* to CIE XYZ D65/2°
XYZ | - X, Y, Z coordinates in the CIEXYZ color space, that refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883). |
luv | - L*u*v* coordinates in the CIE L*u*v* color space. |
|
static |
SBDTypeColor::CIEXYZfromRGB - Converts linear RGB to CIE XYZ with D65/2° standard illuminant.
XYZ | - X, Y and Z give the CIE chromaticies. X, Y, Z output refer to a D65/2° standard illuminant. The CIE XYZ values are scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883) (chromaticity of the white point). |
rgb | - linear R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1). |
|
static |
SBDTypeColor::CIEXYZfromSRGB - Converts device independent standard RGB (sRGB) to CIE XYZ with D65/2° standard illuminant.
XYZ | - X, Y and Z give the CIE chromaticies. X, Y, Z output refer to a D65/2° standard illuminant. The CIE XYZ values are scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883) (chromaticity of the white point). |
rgb | - standard R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1). |
|
static |
SBDTypeColor::cylindricalCIELabfromCIELab - Converts CIE L*a*b* to CIE L*a*b* in cylindrical coordinates (CIE LCh_ab)
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Lab: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
lab | - L*a*b* coordinates in the CIE L*a*b* |
|
static |
SBDTypeColor::cylindricalCIELabfromSRGB - Converts standard RGB (sRGB) to CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab)
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
rgb | - standard RGB (sRGB) |
|
static |
SBDTypeColor::cylindricalCIELuvfromCIELuv - Converts CIE L*u*v* to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv)
hcl | - hue, chroma, and luminance values in the cylindrical CIE L*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
luv | - L*u*v* coordinates in the CIE L*u*v* |
|
static |
SBDTypeColor::cylindricalCIELuvfromSRGB - Converts standard RGB (sRGB) to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv)
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
rgb | - standard RGB (sRGB) |
|
static |
SBDTypeColor::fromHCL - Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to sRGB color as in SBColor.
color | - sRGB color as in SBColor |
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
|
static |
SBDTypeColor::fromHSV - Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor)
color | - sRGB color as in SBColor |
hsv | - hue, saturation, and value |
const float * SBDTypeColor::getColor | ( | ) | const |
Returns a pointer to the color array
|
static |
SBDTypeColor::HCLfromSRGB - Converts standard RGB (sRGB) color to HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv)
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
rgb | - standard RGB (sRGB) color |
|
static |
SBDTypeColor::HSVfromSRGB - Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value)
hsv | - hue, saturation, and value |
rgb | - standard RGB (sRGB) color |
|
static |
SBDTypeColor::RGBfromCIEXYZ - Converts CIE XYZ with D65/2° standard illuminant to linear RGB.
rgb | - linear R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1). |
XYZ | - X, Y and Z are the CIE chromaticies. X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883) |
|
static |
SBDTypeColor::RGBfromSRGB - Converts standard gamma-corrected RGB values to linear RGB values.
rgb | - linear RGB |
srgb | - standard RGB (sRGB) |
|
static |
SBDTypeColor::SRGBfromCIELab - Converts CIE L*a*b* to standard RGB (sRGB)
rgb | - standard RGB (sRGB) |
lab | - L*a*b* coordinates in the CIE L*a*b* color space |
|
static |
SBDTypeColor::SRGBfromCIEXYZ - Converts CIEXYZ with D65/2° standard illuminant to device independent standard RGB (sRGB)
rgb | - standard R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1). |
XYZ | - X, Y and Z are the CIE chromaticies. X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883) |
|
static |
SBDTypeColor::SRGBfromCylindricalCIELab - Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to standard RGB (sRGB)
rgb | - standard RGB (sRGB) |
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
|
static |
SBDTypeColor::SRGBfromCylindricalCIELuv - Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to standard RGB (sRGB)
rgb | - standard RGB (sRGB) |
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
|
static |
SBDTypeColor::SRGBfromHCL - Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to standard RGB (sRGB) color.
rgb | - standard RGB (sRGB) color |
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
|
static |
SBDTypeColor::SRGBfromHSV - Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor)
rgb | - standard RGB (sRGB) color |
hsv | - hue, saturation, and value |
|
static |
SBDTypeColor::SRGBfromRGB - Converts linear RGB values to standard gamma-corrected RGB values.
srgb | - standard RGB (sRGB) |
rgb | - linear RGB |
|
static |
SBDTypeColor::toHCL - Converts sRGB color as in SBColor to HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv)
hcl | - hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100 |
color | - sRGB color as in SBColor |
|
static |
SBDTypeColor::toHSV - Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value)
hsv | - hue, saturation, and value |
color | - sRGB color as in SBColor |