Class SBDTypeColor#
This class describes a color. More...
#include <SBDTypeColor.hpp>
Public Static Attributes#
| Type | Name |
|---|---|
| const SBDTypeColor | black The black color. |
| const SBDTypeColor | blue The blue color. |
| const SBDTypeColor | cyan The cyan color. |
| const SBDTypeColor | defaultKeyframeColor The default keyframe color. |
| const SBDTypeColor | globalXAxis The global X axis color. |
| const SBDTypeColor | globalYAxis The global Y axis color. |
| const SBDTypeColor | globalZAxis The global Z axis color. |
| const SBDTypeColor | green The green color. |
| const SBDTypeColor | ice The frozen color. |
| const SBDTypeColor | localXAxis The local X axis color. |
| const SBDTypeColor | localYAxis The local Y axis color. |
| const SBDTypeColor | localZAxis The local Z axis color. |
| const SBDTypeColor | magenta The magenta color. |
| const SBDTypeColor | orange The orange color. |
| const SBDTypeColor | red The red color. |
| const SBDTypeColor | white The white color. |
| const SBDTypeColor | yellow The yellow color. |
Public Functions#
| Type | Name |
|---|---|
| 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 std::string & hexColor) Constructs a color from hex color. |
|
| SBDTypeColor (const SBDTypeColor & color) Copy constructor. |
|
| SBDTypeColor (SBDTypeColor && color) noexcept Move constructor. |
|
| SBDTypeColor & | bound () Bounds the components within [0, 1]. |
| SBDTypeColor | bounded () const Returns a bounded version of the color with components within [0, 1]. |
| SBDTypeColor & | freeze () Mixes the color with the frozen color. |
| SBDTypeColor | frozen () const Returns a frozen version of the color. |
| 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. |
| 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. |
| 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 with the size of 4. |
| 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. |
| std::string | getRGBString (bool includeAlpha=false) const Returns the RGB[A] string representation of the color as "rgb(r, g, b)" or "rgba(r, g, b, a)" if includeAlpha istrue ; with integer numbers in the [0, 255] interval. |
| float | getRed () const Returns the red component as a floating-point value in the range [0.0, 1.0]. |
| int | getRedInt () const Returns the red component, the value is in the [0.0, 1.0] interval. |
| bool | isSerializable () const Returns true __ |
| bool | operator!= (const SBDTypeColor & color) const Inequality operator. |
| SBDTypeColor | operator* (float f) const Multiply all components by f , including opacity. |
| SBDTypeColor | operator* (const SBDTypeColor & color) const Component-wise multiplication by color , including opacity. |
| SBDTypeColor & | operator*= (float f) Multiply all components by f , including opacity. |
| SBDTypeColor & | operator*= (const SBDTypeColor & color) Component-wise multiplication by color , including opacity. |
| SBDTypeColor | operator+ (const SBDTypeColor & color) const Component-wise addition by color , including opacity. |
| SBDTypeColor & | operator+= (const SBDTypeColor & color) Component-wise addition by color , including opacity. |
| SBDTypeColor | operator- (const SBDTypeColor & color) const Component-wise subtraction by color , including opacity. |
| SBDTypeColor & | operator-= (const SBDTypeColor & color) Component-wise subtraction by color , including opacity. |
| SBDTypeColor & | operator= (const SBDTypeColor & color) Copy assignment. |
| SBDTypeColor & | operator= (SBDTypeColor && color) noexcept Move assignment. |
| bool | operator== (const SBDTypeColor & color) const Equality operator. |
| float & | operator[] (int index) Returns a reference to component index . |
| const float & | operator[] (int index) const Returns a reference to component index (const version) |
| virtual void | print (unsigned int offset=0) const Prints the color. |
| void | serialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER) const Serializes the color. |
| 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. |
| 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. |
| 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. |
| 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. |
| double | toGrayscale () const Returns the grayscale representation of the color. |
| std::string | toHex (bool includeAlpha=false) const Returns the hex representation of the color. |
| virtual std::string | toPythonCode () const Returns the string representation of the object that can be used to reconstruct it in Python. |
| void | unserialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER) Unserializes the color. |
| virtual | ~SBDTypeColor () Destructs the color. |
Public Static Functions#
| Type | Name |
|---|---|
| void | CIELabfromCIEXYZ (float * lab, float * XYZ) Converts CIE XYZ D65/2° to CIE L*a*b*. |
| 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*. |
| void | CIELabfromSRGB (float * lab, float * rgb) Converts color from standard RGB (sRGB) color space to CIE L*a*b* color space. |
| void | CIELuvfromCIEXYZ (float * luv, float * XYZ) Converts CIE XYZ D65/2° to CIE L*u*v*. |
| 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*. |
| void | CIEXYZfromCIELab (float * XYZ, float * lab) Converts CIE L*a*b* to CIE XYZ D65/2° |
| void | CIEXYZfromCIELuv (float * XYZ, float * luv) Converts CIE L*u*v* to CIE XYZ D65/2° |
| void | CIEXYZfromRGB (float * XYZ, float * rgb) Converts linear RGB to CIE XYZ with D65/2° standard illuminant. |
| void | CIEXYZfromSRGB (float * XYZ, float * rgb) Converts device independent standard RGB (sRGB) to CIE XYZ with D65/2° standard illuminant. |
| void | CIEuvfromCIEXYZ (float * uv, float * XYZ) Converts CIE XYZ D65/2° to u and v coordinates for the CIE Luv. |
| 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) |
| void | HSVfromSRGB (float * hsv, float * rgb) Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value) |
| void | RGBfromCIEXYZ (float * rgb, float * XYZ) Converts CIE XYZ with D65/2° standard illuminant to linear RGB. |
| void | RGBfromSRGB (float * rgb, float * srgb) Converts standard RGB (sRGB) values to linear RGB values. |
| void | SRGBfromCIELab (float * rgb, float * lab) Converts color from CIE L*a*b* color space to standard RGB (sRGB) color space. |
| void | SRGBfromCIEXYZ (float * rgb, float * XYZ) Converts CIEXYZ with D65/2° standard illuminant to device independent standard RGB (sRGB) |
| void | SRGBfromCylindricalCIELab (float * rgb, float * hcl) Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to standard RGB (sRGB) |
| void | SRGBfromCylindricalCIELuv (float * rgb, float * hcl) Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to standard RGB (sRGB) |
| 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. |
| void | SRGBfromHSV (float * rgb, float * hsv) Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor) |
| void | SRGBfromRGB (float * srgb, float * rgb) Converts linear RGB values to standard RGB (sRGB) values. |
| double | SRGBtoGrayscale (double r, double g, double b) Converts sRGB to grayscale. |
| 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) |
| void | cylindricalCIELabfromSRGB (float * hcl, float * rgb) Converts standard RGB (sRGB) to CIE L*a*b* in cylindrical coordinates a.k.a. (CIE LCh_ab) |
| 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) |
| void | cylindricalCIELuvfromSRGB (float * hcl, float * rgb) Converts standard RGB (sRGB) to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) |
| void | darkenSRGBColor (float * rgb, float amount) Darkens the standard RGB (sRGB) color rgb by the amountamount . |
| SBDTypeColor | fromHCL (float hue, float chroma, float luminance) Creates a color from a given HCL (CIE LCh_uv) color. |
| 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) |
| SBDTypeColor | fromHSV (float hue, float saturation, float value) Creates a color from a given HSV color. |
| void | fromHSV (float * color, float * hsv) Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor) |
| void | lightenSRGBColor (float * rgb, float amount) Lightens the standard RGB (sRGB) color rgb by the amountamount . |
| 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) |
| void | toHSV (float * hsv, float * color) Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value) |
Protected Attributes#
| Type | Name |
|---|---|
| SBDTypeColorData * | dataPointer A pointer to the private data. |
Detailed Description#
This class describes a color in SAMSON.
Please refer to the Color schemes for more information.
Short name: SBColor
SBColor uses the standard RGB (sRGB).
Color conversions#
This class also provides static functions to transform colors between different color spaces:
- standard gamma-corrected RGB (sRGB)
- RGB
- HSV (hue, saturation, value)
- HCL (hue, chroma, luminance) - cylindrical representation of CIE L*u*v*, a.k.a. CIE LCh_uv
- CIE L*u*v*
- CIE L*a*b*
- CIE L*a*b* in cylindrical coordinates, a.k.a. CIE LCh_ab
- CIE XYZ with D65/2° standard illuminant.
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:
float color_in_sRGB[3] = {1.0, 0.0, 0.0}; // red color in sRGB color space
float color_in_HCL[3];
SBColor::toHCL(color_in_HCL, color_in_sRGB);
Note: The conversions might not always be exact. For example, a conversion 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 arithmetic.
See also: Color schemes, SBDPalette
Public Static Attributes Documentation#
variable black#
The black color.
variable blue#
The blue color.
variable cyan#
The cyan color.
variable defaultKeyframeColor#
The default keyframe color.
variable globalXAxis#
The global X axis color.
variable globalYAxis#
The global Y axis color.
variable globalZAxis#
The global Z axis color.
variable green#
The green color.
variable ice#
The frozen color.
variable localXAxis#
The local X axis color.
variable localYAxis#
The local Y axis color.
variable localZAxis#
The local Z axis color.
variable magenta#
The magenta color.
variable orange#
The orange color.
variable red#
The red color.
variable white#
The white color.
variable yellow#
The yellow color.
Public Functions Documentation#
function SBDTypeColor [1/8]#
Constructs a color (1.0f, 1.0f, 1.0f, 1.0f)
Constructs a default color (white with full opacity).
Creates a color with red, green, blue components set to 1.0 and alpha set to 1.0.
function SBDTypeColor [2/8]#
Constructs a color (red, green, blue, alpha)
Constructs a color from floating-point components.
Creates a color with the specified red, green, blue, and alpha components.
Parameters:
redRed component in the [0.0, 1.0] range.greenGreen component in the [0.0, 1.0] range.blueBlue component in the [0.0, 1.0] range.alphaAlpha component in the [0.0, 1.0] range (default = 1.0).
function SBDTypeColor [3/8]#
Constructs a color (red, green, blue, alpha)
Constructs a color from integer components.
Creates a color with the specified red, green, blue, and alpha components given as integers in the [0, 255] range.
Parameters:
redRed component in the [0, 255] range.greenGreen component in the [0, 255] range.blueBlue component in the [0, 255] range.alphaAlpha component in the [0, 255] range (default = 255).
function SBDTypeColor [4/8]#
Constructs a color (red, green, blue, alpha)
SBDTypeColor::SBDTypeColor (
unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char alpha=255
)
Constructs a color from unsigned byte components.
Creates a color with the specified red, green, blue, and alpha components given as unsigned bytes (0-255).
Parameters:
redRed component (0-255).greenGreen component (0-255).blueBlue component (0-255).alphaAlpha component (0-255, default = 255).
function SBDTypeColor [5/8]#
Constructs a color (color[0], color[1], color[2], color[3])
Constructs a color from an array of four floats.
The array must contain the red, green, blue, and alpha components in that order.
Parameters:
colorPointer to an array of four floats representing the color components.
function SBDTypeColor [6/8]#
Constructs a color from hex color.
Creates a color from a hexadecimal color string.
The hex color can start with '#' or not and should contain a hex triplet (six‑digit) or hex quadruplet (eight‑digit) representing RGBA.
Examples:
Parameters:
hexColorHexadecimal color string, optionally prefixed with '#'.
function SBDTypeColor [7/8]#
Copy constructor.
Creates a new color with the same component values as the source color.
Parameters:
colorSource color to copy.
function SBDTypeColor [8/8]#
Move constructor.
Constructs a new color by moving the component values from the source color. The source color is left in a valid but unspecified state.
Parameters:
colorSource color to move from.
function bound#
Bounds the components within [0, 1].
Clamps the color components to the range [0, 1].
Ensures each component (red, green, blue, alpha) lies within the interval [0, 1].
Returns:
Reference to this color after bounding.
function bounded#
Returns a bounded version of the color with components within [0, 1].
Returns a bounded copy of the color.
Creates a new color whose components are clamped to the range [0, 1].
Returns:
New color with components bounded to [0, 1].
function freeze#
Mixes the color with the frozen color.
Blends this color with the predefined frozen color (ice) using a fixed weighting (20 % original, 80 % frozen).
Returns:
Reference to this color after freezing.
function frozen#
Returns a frozen version of the color.
The frozen version blends the current color with the predefined frozen color using a fixed ratio of 20% of the original color and 80% of the frozen color.
Returns:
A new SBDTypeColor representing the frozen color.
function getAlpha#
Sets the blue component, the value should be in the [0.0, 1.0] interval.
Returns the alpha component as a floating-point value in the range [0.0, 1.0].
Returns:
The alpha component.
function getAlphaInt#
Returns the alpha component, the value is in the [0.0, 1.0] interval.
Returns the alpha component as an integer in the range [0, 255].
Returns:
The alpha component as an integer.
function getBlue#
Sets the green component, the value should be in the [0.0, 1.0] interval.
Returns the blue component as a floating-point value in the range [0.0, 1.0].
Returns:
The blue component.
function getBlueInt#
Returns the blue component, the value is in the [0.0, 1.0] interval.
Returns the blue component as an integer in the range [0, 255].
Returns:
The blue component as an integer.
function getColor [1/2]#
Sets the alpha component, the value should be in the [0.0, 1.0] interval.
Returns a pointer to the internal color array (red, green, blue, alpha).
Returns a pointer to the color array (size of 4)
The returned pointer may be nullptr if the internal data is unavailable.
Returns:
Pointer to an array of four floats, or nullptr.
function getColor [2/2]#
Stores the four components as a float array with the size of 4.
Copies the color components into a user-provided array.
The destination array must have space for four float values.
Parameters:
colorDestination array to receive the color components (size 4).
function getGreen#
Sets the red component, the value should be in the [0.0, 1.0] interval.
Returns the green component as a floating-point value in the range [0.0, 1.0].
Returns:
The green component.
function getGreenInt#
Returns the green component, the value is in the [0.0, 1.0] interval.
Returns the green component as an integer in the range [0, 255].
Returns:
The green component as an integer.
function getRGBString#
Returns the RGB[A] string representation of the color as "rgb(r, g, b)" or "rgba(r, g, b, a)" if includeAlpha istrue ; with integer numbers in the [0, 255] interval.
Returns the RGB[A] string representation of the color.
Format: "rgb(r, g, b)" or "rgba(r, g, b, a)" when includeAlpha is true. The components are integers in the range [0, 255].
Parameters:
includeAlphaIftrue, includes the alpha component in the output string.
Returns:
Formatted RGB or RGBA string.
function getRed#
Returns the red component as a floating-point value in the range [0.0, 1.0].
Returns:
The red component.
function getRedInt#
Returns the red component, the value is in the [0.0, 1.0] interval.
Returns the red component as an integer in the range [0, 255].
Returns:
The red component as an integer.
function isSerializable#
Returns true __
Checks whether the color type is serializable.
This function always returns true for SBDTypeColor.
Returns:
true indicating that the object can be serialized.
function operator!=#
Inequality operator.
Determines whether two colors differ in any component.
Parameters:
colorOther color to compare with.
Returns:
true if any component differs; otherwise false.
function operator*#
Multiply all components by f , including opacity.
Scales the color by a factor.
Multiplies each component (red, green, blue, alpha) by the given factor and returns a new color.
Parameters:
fScaling factor.
Returns:
New color with scaled components.
function operator*#
Component-wise multiplication by color , including opacity.
Component‑wise multiplication of two colors.
Multiplies the corresponding components of this color and the given color, returning a new color.
Parameters:
colorOther color to multiply with.
Returns:
New color resulting from component‑wise multiplication.
function operator*=#
Multiply all components by f , including opacity.
Scales this color by a factor in-place.
Multiplies each component of this color by the given factor.
Parameters:
fScaling factor.
Returns:
Reference to this color after scaling.
function operator*=#
Component-wise multiplication by color , including opacity.
Component‑wise multiplication in‑place.
Multiplies each component of this color by the corresponding component of the given color.
Parameters:
colorOther color to multiply with.
Returns:
Reference to this color after multiplication.
function operator+#
Component-wise addition by color , including opacity.
Component‑wise addition of two colors.
Adds the corresponding components of this color and the given color, returning a new color.
Parameters:
colorOther color to add.
Returns:
New color resulting from component‑wise addition.
function operator+=#
Component-wise addition by color , including opacity.
Component‑wise addition in‑place.
Adds each component of the given color to this color.
Parameters:
colorOther color to add.
Returns:
Reference to this color after addition.
function operator-#
Component-wise subtraction by color , including opacity.
Component‑wise subtraction of two colors.
Subtracts the corresponding components of the given color from this color, returning a new color.
Parameters:
colorOther color to subtract.
Returns:
New color resulting from component‑wise subtraction.
function operator-=#
Component-wise subtraction by color , including opacity.
Component‑wise subtraction in‑place.
Subtracts each component of the given color from this color.
Parameters:
colorOther color to subtract.
Returns:
Reference to this color after subtraction.
function operator=#
Copy assignment.
Copy assignment operator.
Copies the color components from another color.
Parameters:
colorSource color to copy from.
Returns:
Reference to this color after assignment.
function operator=#
Move assignment.
Move assignment operator.
Moves the color components from another color into this one.
Parameters:
colorSource color to move from.
Returns:
Reference to this color after move assignment.
function operator==#
Equality operator.
Determines whether two colors have identical component values.
Parameters:
colorOther color to compare with.
Returns:
true if all components are equal; otherwise false.
function operator[]#
Returns a reference to component index .
Provides mutable access to a color component by index.
Index 0 = red, 1 = green, 2 = blue, 3 = alpha.
Parameters:
indexComponent index (0-3).
Returns:
Reference to the requested component.
function operator[]#
Returns a reference to component index (const version)
Provides read-only access to a color component by index.
Index 0 = red, 1 = green, 2 = blue, 3 = alpha.
Parameters:
indexComponent index (0-3).
Returns:
Const reference to the requested component.
function print#
Prints the color.
Prints the color to standard output with optional indentation.
Each component is printed as a floating-point value.
Parameters:
offsetNumber of tab characters to prepend before printing.
function serialize#
Serializes the color.
void SBDTypeColor::serialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
) const
Serializes the color to a serializer.
Writes the color components (red, green, blue, alpha) to the given serializer.
Parameters:
serializerPointer to the serializer used for writing the data.sdkVersionNumberVersion number of the SDK; defaults to SB_SDK_VERSION_NUMBER.
function setAlpha [1/2]#
Returns the alpha component, the value is in the [0, 255] interval.
Sets the alpha component using an integer value in the range [0, 255].
Parameters:
alphaAlpha component as an integer.
function setAlpha [2/2]#
Sets the alpha component, the value should be in the [0, 255] interval.
Sets the alpha component using a floating-point value in the range [0.0, 1.0].
Parameters:
alphaAlpha component as a float.
function setBlue [1/2]#
Returns the blue component, the value is in the [0, 255] interval.
Sets the blue component using an integer value in the range [0, 255].
Parameters:
blueBlue component as an integer.
function setBlue [2/2]#
Sets the blue component, the value should be in the [0, 255] interval.
Sets the blue component using a floating-point value in the range [0.0, 1.0].
Parameters:
blueBlue component as a float.
function setGreen [1/2]#
Returns the green component, the value is in the [0, 255] interval.
Sets the green component using an integer value in the range [0, 255].
Parameters:
greenGreen component as an integer.
function setGreen [2/2]#
Sets the green component, the value should be in the [0, 255] interval.
Sets the green component using a floating-point value in the range [0.0, 1.0].
Parameters:
greenGreen component as a float.
function setRed [1/2]#
Returns the red component, the value is in the [0, 255] interval.
Sets the red component using an integer value in the range [0, 255].
Parameters:
redRed component as an integer.
function setRed [2/2]#
Sets the red component, the value should be in the [0, 255] interval.
Sets the red component using a floating-point value in the range [0.0, 1.0].
Parameters:
redRed component as a float.
function toGrayscale#
Returns the grayscale representation of the color.
The grayscale value is computed as 0.299 * R + 0.587 * G + 0.114 * B.
Returns:
Grayscale value as a double.
function toHex#
Returns the hex representation of the color.
Returns the hexadecimal representation of the color, prefixed with '#'.
The result is a six-digit hex string for RGB or an eight-digit string for RGBA when includeAlpha is true.
Parameters:
includeAlphaIftrue, includes the alpha component in the hex string.
Returns:
Hexadecimal color string.
function toPythonCode#
Returns the string representation of the object that can be used to reconstruct it in Python.
Returns a Python code representation of the color.
The string can be used to reconstruct the SBColor object in Python.
Returns:
Python code string for this color.
function unserialize#
Unserializes the color.
void SBDTypeColor::unserialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
)
Unserializes the color from a serializer.
Reads the color components (red, green, blue, alpha) from the given serializer.
Parameters:
serializerPointer to the serializer used for reading the data.sdkVersionNumberVersion number of the SDK; defaults to SB_SDK_VERSION_NUMBER.
function ~SBDTypeColor#
Destructs the color.
Destructor.
Destroys the color and releases any allocated resources.
Public Static Functions Documentation#
function CIELabfromCIEXYZ#
Converts CIE XYZ D65/2° to CIE L*a*b*.
SBDTypeColor::CIELabfromCIEXYZ - Converts CIE XYZ D65/2° to CIE L*a*b*.
Parameters:
lab- CIE L*a*b* coordinatesXYZ- 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)
function CIELabfromCylindricalCIELab#
Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to CIE L*a*b*.
SBDTypeColor::CIELabfromCylindricalCIELab - Converts CIE L*a*b* in cylindrical coordinates (CIE LCh_ab) to CIE L*a*b*.
Parameters:
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
function CIELabfromSRGB#
Converts color from standard RGB (sRGB) color space to CIE L*a*b* color space.
SBDTypeColor::CIELabfromSRGB - Converts standard RGB (sRGB) to CIE L*a*b*.
Parameters:
lab- L*a*b* coordinates in the CIE L*a*b* color spacergb- standard RGB (sRGB)
function CIELuvfromCIEXYZ#
Converts CIE XYZ D65/2° to CIE L*u*v*.
SBDTypeColor::CIELuvfromCIEXYZ - Converts CIE XYZ D65/2° to CIE L*u*v*.
Parameters:
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).
function CIELuvfromCylindricalCIELuv#
Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to CIE L*u*v*.
SBDTypeColor::CIELuvfromCylindricalCIELuv - Converts CIE L*u*v* in cylindrical coordinates (a.k.a.
CIE LCh_uv) to CIE L*u*v*
Parameters:
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
function CIEXYZfromCIELab#
Converts CIE L*a*b* to CIE XYZ D65/2°
SBDTypeColor::CIEXYZfromCIELab - Converts CIE L*a*b* to CIE XYZ D65/2°
Parameters:
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
function CIEXYZfromCIELuv#
Converts CIE L*u*v* to CIE XYZ D65/2°
SBDTypeColor::CIEXYZfromCIELuv - Converts CIE L*u*v* to CIE XYZ D65/2°
Parameters:
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.
function CIEXYZfromRGB#
Converts linear RGB to CIE XYZ with D65/2° standard illuminant.
SBDTypeColor::CIEXYZfromRGB - Converts linear RGB to CIE XYZ with D65/2° standard illuminant.
Parameters:
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).
function CIEXYZfromSRGB#
Converts device independent standard RGB (sRGB) to CIE XYZ with D65/2° standard illuminant.
SBDTypeColor::CIEXYZfromSRGB - Converts device independent standard RGB (sRGB) to CIE XYZ with D65/2° standard illuminant.
Parameters:
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).
function CIEuvfromCIEXYZ#
Converts CIE XYZ D65/2° to u and v coordinates for the CIE Luv.
SBDTypeColor::CIEuvfromCIEXYZ - An auxiliary function that computes u and v coordinates for the CIE Luv from CIE XYZ.
Parameters:
uv- u and v valuesXYZ- 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).
function HCLfromSRGB#
Converts standard RGB (sRGB) color to HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv)
SBDTypeColor::HCLfromSRGB - Converts standard RGB (sRGB) color to HCL color (cylindrical representation of CIE L*u*v* a.k.a.
CIE LCh_uv)
Parameters:
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 ... 100rgb- standard RGB (sRGB) color
function HSVfromSRGB#
Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value)
SBDTypeColor::HSVfromSRGB - Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value)
Parameters:
hsv- hue, saturation, and valuergb- standard RGB (sRGB) color
function RGBfromCIEXYZ#
Converts CIE XYZ with D65/2° standard illuminant to linear RGB.
SBDTypeColor::RGBfromCIEXYZ - Converts CIE XYZ with D65/2° standard illuminant to linear RGB.
Parameters:
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)
function RGBfromSRGB#
Converts standard RGB (sRGB) values to linear RGB values.
SBDTypeColor::RGBfromSRGB - Converts standard gamma-corrected RGB values to linear RGB values.
Parameters:
rgb- linear RGBsrgb- standard RGB (sRGB)
function SRGBfromCIELab#
Converts color from CIE L*a*b* color space to standard RGB (sRGB) color space.
SBDTypeColor::SRGBfromCIELab - Converts CIE L*a*b* to standard RGB (sRGB)
Parameters:
rgb- standard RGB (sRGB)lab- L*a*b* coordinates in the CIE L*a*b* color space
function SRGBfromCIEXYZ#
Converts CIEXYZ with D65/2° standard illuminant to device independent standard RGB (sRGB)
SBDTypeColor::SRGBfromCIEXYZ - Converts CIEXYZ with D65/2° standard illuminant to device independent standard RGB (sRGB)
Parameters:
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 chromaticities. 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)
function SRGBfromCylindricalCIELab#
Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to standard RGB (sRGB)
SBDTypeColor::SRGBfromCylindricalCIELab - Converts CIE L*a*b* in cylindrical coordinates (a.k.a.
CIE LCh_ab) to standard RGB (sRGB)
Parameters:
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
function SRGBfromCylindricalCIELuv#
Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to standard RGB (sRGB)
SBDTypeColor::SRGBfromCylindricalCIELuv - Converts CIE L*u*v* in cylindrical coordinates (a.k.a.
CIE LCh_uv) to standard RGB (sRGB)
Parameters:
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
function SRGBfromHCL#
Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to standard RGB (sRGB) color.
SBDTypeColor::SRGBfromHCL - Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a.
CIE LCh_uv) to standard RGB (sRGB) color
Parameters:
rgb- standard RGB (sRGB) colorhcl- 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
function SRGBfromHSV#
Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor)
SBDTypeColor::SRGBfromHSV - Converts HSV color (Hue, Saturation, Value) to sRGB color (as in SBColor)
Parameters:
rgbOutput array (size 3) receiving the sRGB color components.hsvInput array (size 3) containing hue, saturation, and value components.
function SRGBfromRGB#
Converts linear RGB values to standard RGB (sRGB) values.
SBDTypeColor::SRGBfromRGB - Converts linear RGB values to standard gamma-corrected RGB values.
Parameters:
srgb- standard RGB (sRGB)rgb- linear RGB
function SRGBtoGrayscale#
Converts sRGB to grayscale.
Converts sRGB components to a grayscale value.
The calculation uses the formula 0.299 * R + 0.587 * G + 0.114 * B.
Parameters:
rRed component in the range [0.0, 1.0].gGreen component in the range [0.0, 1.0].bBlue component in the range [0.0, 1.0].
Returns:
Grayscale value as a double.
function cylindricalCIELabfromCIELab#
Converts CIE L*a*b* to CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab)
SBDTypeColor::cylindricalCIELabfromCIELab - Converts CIE L*a*b* to CIE L*a*b* in cylindrical coordinates (CIE LCh_ab)
Parameters:
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 ... 100lab- L*a*b* coordinates in the CIE L*a*b*
function cylindricalCIELabfromSRGB#
Converts standard RGB (sRGB) to CIE L*a*b* in cylindrical coordinates a.k.a. (CIE LCh_ab)
SBDTypeColor::cylindricalCIELabfromSRGB - Converts standard RGB (sRGB) to CIE L*a*b* in cylindrical coordinates (a.k.a.
CIE LCh_ab)
Parameters:
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 ... 100rgb- standard RGB (sRGB)
function cylindricalCIELuvfromCIELuv#
Converts CIE L*u*v* to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv)
SBDTypeColor::cylindricalCIELuvfromCIELuv - Converts CIE L*u*v* to CIE L*u*v* in cylindrical coordinates (a.k.a.
CIE LCh_uv)
Parameters:
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 ... 100luv- L*u*v* coordinates in the CIE L*u*v*
function cylindricalCIELuvfromSRGB#
Converts standard RGB (sRGB) to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv)
SBDTypeColor::cylindricalCIELuvfromSRGB - Converts standard RGB (sRGB) to CIE L*u*v* in cylindrical coordinates (a.k.a.
CIE LCh_uv)
Parameters:
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 ... 100rgb- standard RGB (sRGB)
function darkenSRGBColor#
Darkens the standard RGB (sRGB) color rgb by the amountamount .
SBDTypeColor::darkenSRGBColor - Darkens the given sRGB color by a specified amount.
Parameters:
rgb- Array (size 3) containing the sRGB color components to be darkened; modified in place.amount- Amount to darken the color; positive values darken, negative values lighten.
function fromHCL [1/2]#
Creates a color from a given HCL (CIE LCh_uv) color.
Creates a color from HCL (Hue, Chroma, Luminance) components.
The resulting color has an alpha component of 1.0.
Parameters:
hueHue component.chromaChroma component.luminanceLuminance component.
Returns:
A new SBDTypeColor representing the HCL color.
function fromHCL [2/2]#
Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to sRGB color (as in SBColor)
SBDTypeColor::fromHCL - Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a.
CIE LCh_uv) to sRGB color as in SBColor
Parameters:
color- sRGB color as in SBColorhcl- 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
function fromHSV [1/2]#
Creates a color from a given HSV color.
Creates a color from HSV (Hue, Saturation, Value) components.
The resulting color has an alpha component of 1.0.
Parameters:
hueHue component (typically [0, 360] or [0, 1]).saturationSaturation component in the range [0.0, 1.0].valueValue component in the range [0.0, 1.0].
Returns:
A new SBDTypeColor representing the HSV color.
function fromHSV [2/2]#
Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor)
SBDTypeColor::fromHSV - Converts HSV color (Hue Saturation Value) to sRGB color (as in SBColor)
Parameters:
color- sRGB color as in SBColorhsv- hue, saturation, and value
function lightenSRGBColor#
Lightens the standard RGB (sRGB) color rgb by the amountamount .
SBDTypeColor::lightenSRGBColor - Lightens the given sRGB color by a specified amount.
Parameters:
rgb- Array (size 3) containing the sRGB color components to be lightened; modified in place.amount- Amount to lighten the color; positive values lighten.
function toHCL#
Converts sRGB color (as in SBColor) to HCL (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv)
SBDTypeColor::toHCL - Converts sRGB color as in SBColor to HCL color (cylindrical representation of CIE L*u*v* a.k.a.
CIE LCh_uv)
Parameters:
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 ... 100color- sRGB color as in SBColor
function toHSV#
Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value)
SBDTypeColor::toHSV - Converts sRGB color (as in SBColor) to HSV (Hue Saturation Value)
Parameters:
hsv- hue, saturation, and valuecolor- sRGB color as in SBColor
Protected Attributes Documentation#
variable dataPointer#
A pointer to the private data.