Rhino C++ API
8.10
|
#include <opennurbs_color.h>
Public Types | |
enum | RGBA_byte_index : unsigned int { kRedByteIndex = 0, kGreenByteIndex = 1, kBlueByteIndex = 2, kAlphaByteIndex = 3 } |
enum | RGBA_shift : unsigned int |
enum | TextFormat : unsigned char { TextFormat::Unset = 0, TextFormat::FractionalRGB = 1, TextFormat::FractionalRGBa = 2, TextFormat::FractionalRGBA = 3, TextFormat::DecimalRGB = 4, TextFormat::DecimalRGBa = 5, TextFormat::DecimalRGBA = 6, TextFormat::HexadecimalRGB = 7, TextFormat::HexadecimalRGBa = 8, TextFormat::HexadecimalRGBA = 9, TextFormat::HSV = 10, TextFormat::HSVa = 11, TextFormat::HSVA = 12, TextFormat::HashRGB = 13, TextFormat::HashRGBa = 14, TextFormat::HashRGBA = 15 } |
Public Member Functions | |
ON_Color ()=default | |
ON_Color (const ON_Color &)=default | |
ON_Color (int red, int green, int blue) | |
Sets A = 0. More... | |
ON_Color (int red, int green, int blue, int alpha) | |
ON_Color (unsigned int colorref) | |
~ON_Color ()=default | |
int | Alpha () const |
( 0 to 255 ) (0 = opaque, 255 = transparent) More... | |
int | Blue () const |
( 0 to 255 ) More... | |
int | Compare (const ON_Color &) const |
< 0 if this < arg, 0 ir this==arg, > 0 if this > arg More... | |
double | FractionAlpha () const |
( 0.0 to 1.0 ) (0.0 = opaque, 1.0 = transparent) More... | |
double | FractionBlue () const |
( 0.0 to 1.0 ) More... | |
double | FractionGreen () const |
( 0.0 to 1.0 ) More... | |
double | FractionRed () const |
( 0.0 to 1.0 ) More... | |
int | Green () const |
( 0 to 255 ) More... | |
double | Hue () const |
bool | IsSet () const |
| |
bool | IsUnset () const |
| |
operator unsigned int () const | |
Conversion to Windows COLORREF in little endian RGBA order. More... | |
ON_Color & | operator= (const ON_Color &)=default |
int | Red () const |
( 0 to 255 ) More... | |
double | Saturation () const |
Returns 0.0 (gray) to 1.0 (saturated) More... | |
void | SetAlpha (int alpha) |
void | SetFractionalAlpha (double alpha) |
void | SetFractionalRGB (double red, double green, double blue) |
void | SetFractionalRGBA (double red, double green, double blue, double alpha) |
input args More... | |
void | SetHSV (double h, double s, double v) |
Specify a color using HSV (hue, saturation, value). If h, s or v are not in the open interval (ON_UNSET_FLOAT,ON_UNSET_POSITIVE_FLOAT), then this color is set to ON_Color::UnsetColor. More... | |
void | SetRGB (int red, int green, int blue) |
void | SetRGBA (int red, int green, int blue, int alpha) |
const ON_wString | ToString (ON_Color::TextFormat format, wchar_t separator, bool bFormatUnsetColor) const |
const ON_wString | ToString (ON_Color::TextFormat format, wchar_t separator, bool bFormatUnsetColor, class ON_TextLog &ignored_parameter) const |
void | ToText (ON_Color::TextFormat format, wchar_t separator, bool bFormatUnsetColor, class ON_TextLog &text_log) const |
double | Value () const |
Returns 0.0 (black) to 1.0 (white) More... | |
unsigned int | WindowsRGB () const |
Static Public Member Functions | |
static const ON_Color | FromHueInRadians (double hue_in_radians) |
Get the saturated color with the specified hue. More... | |
static const ON_Color | RandomColor () |
static const ON_Color | RandomColor (ON__UINT32 seed) |
static const ON_Color | RandomColor (ON__UINT32 seed, ON_Interval hue_range, ON_Interval saturation_range, ON_Interval value_range) |
static const ON_Color | RandomColor (ON_Interval hue_range, ON_Interval saturation_range, ON_Interval value_range) |
Static Public Attributes | |
static const ON_Color | Black |
0x00000000u More... | |
static const ON_Color | Gray105 |
R = G = B = 105 (medium dark) More... | |
static const ON_Color | Gray126 |
R = G = B = 128 (medium) More... | |
static const ON_Color | Gray160 |
R = G = B = 160 (medium light) More... | |
static const ON_Color | Gray230 |
R = G = B = 230 (light) More... | |
static const ON_Color | Gray250 |
R = G = B = 250 (lightest) More... | |
static const ON_Color | SaturatedBlue |
0x00FF0000u on little endian, 0x0000FF00u on big endian More... | |
static const ON_Color | SaturatedCyan |
0x00FFFF00u on little endian, 0x00FFFF00u on big endian More... | |
static const ON_Color | SaturatedGold |
0x0000BFFFu on little endian, 0xFFBF0000u on big endian More... | |
static const ON_Color | SaturatedGreen |
0x0000FF00u on little endian, 0x00FF0000u on big endian More... | |
static const ON_Color | SaturatedMagenta |
0x00FF00FFu on little endian, 0xFF00FF00u on big endian More... | |
static const ON_Color | SaturatedRed |
0x000000FFu on little endian, 0xFF000000u on big endian More... | |
static const ON_Color | SaturatedYellow |
0x0000FFFFu on little endian, 0xFFFF0000u on big endian More... | |
static const ON_Color | UnsetColor |
0xFFFFFFFFu More... | |
static const ON_Color | White |
0x00FFFFFFu on little endian, 0xFFFFFF00u on big endian More... | |
Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved. OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert McNeel & Associates.
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
For complete openNURBS copyright information see http://www.opennurbs.org. Class ON_Color
enum ON_Color::RGBA_byte_index : unsigned int |
If you need to use byte indexing to convert RGBA components to and from an unsigned int ON_Color value and want your code to work on both little and big endian computers, then use the RGBA_byte_index enum.
unsigned int u; unsigned char* rgba = rbga[ON_Color::kRedByteIndex] = red value 0 to 255. rbga[ON_Color::kGreenByteIndex] = green value 0 to 255. rbga[ON_Color::kBlueByteIndex] = blue value 0 to 255. rbga[ON_Color::kAlphaByteIndex] = alpha value 0 to 255. ON_Color color = u;
Enumerator | |
---|---|
kRedByteIndex | same for both little and big endian computers. |
kGreenByteIndex | |
kBlueByteIndex | |
kAlphaByteIndex |
enum ON_Color::RGBA_shift : unsigned int |
If you need to use shifting to convert RGBA components to and from an unsigned int ON_Color value and you want your code to work on both little and big endian computers, use the RGBA_shift enum.
unsigned int u = 0; u |= ((((unsigned int)red) & 0xFFU) << ON_Color::RGBA_shift::kRedShift); u |= ((((unsigned int)green) & 0xFFU) << ON_Color::RGBA_shift::kGreenShift); u |= ((((unsigned int)blue) & 0xFFU) << ON_Color::RGBA_shift::kBlueShift); u |= ((((unsigned int)alpha) & 0xFFU) << ON_Color::RGBA_shift::kAlphaShift); ON_Color color = u;
|
strong |
|
default |
|
default |
|
default |
ON_Color::ON_Color | ( | int | red, |
int | green, | ||
int | blue | ||
) |
Sets A = 0.
red | ( 0 to 255 ) |
green | ( 0 to 255 ) |
blue | ( 0 to 255 ) |
ON_Color::ON_Color | ( | int | red, |
int | green, | ||
int | blue, | ||
int | alpha | ||
) |
red | ( 0 to 255 ) |
green | ( 0 to 255 ) |
blue | ( 0 to 255 ) |
alpha | ( 0 to 255 ) (0 = opaque, 255 = transparent) |
ON_Color::ON_Color | ( | unsigned int | colorref | ) |
Parameters: colorref - [in] Windows COLORREF in little endian RGBA order.
int ON_Color::Alpha | ( | ) | const |
( 0 to 255 ) (0 = opaque, 255 = transparent)
int ON_Color::Blue | ( | ) | const |
( 0 to 255 )
int ON_Color::Compare | ( | const ON_Color & | ) | const |
< 0 if this < arg, 0 ir this==arg, > 0 if this > arg
double ON_Color::FractionAlpha | ( | ) | const |
( 0.0 to 1.0 ) (0.0 = opaque, 1.0 = transparent)
double ON_Color::FractionBlue | ( | ) | const |
( 0.0 to 1.0 )
double ON_Color::FractionGreen | ( | ) | const |
( 0.0 to 1.0 )
double ON_Color::FractionRed | ( | ) | const |
( 0.0 to 1.0 )
|
static |
Get the saturated color with the specified hue.
hue_in_radians | 0 = red, pi/3 = yellow, 2pi/3 = green, pi = cyan, 4pi/3 = blue, 5pi/3 = magenta, 2pi = red |
int ON_Color::Green | ( | ) | const |
( 0 to 255 )
double ON_Color::Hue | ( | ) | const |
Hue() returns an angle in radians in the range 0 to 2*pi. 0 = red, pi/3 = yellow, 2pi/3 = green, pi = cyan, 4pi/3 = blue, 5pi/3 = magenta, 2pi = red
bool ON_Color::IsSet | ( | ) | const |
bool ON_Color::IsUnset | ( | ) | const |
ON_Color::operator unsigned int | ( | ) | const |
Conversion to Windows COLORREF in little endian RGBA order.
|
static |
Returns: A random color.
|
static |
Returns: A color generated from seed. The color for a given seed will always be the same.
|
static |
Parameters: seed - [in] hue_range - [in] range of hues. Use ON_Interval::ZeroToTwoPi for all hues. 0 = red, pi/3 = yellow, 2pi/3 = green, pi = cyan, 4pi/3 = blue, 5pi/3 = magenta, 2pi = red saturation_range - [in] range of saturations. Use ON_Interval::ZeroToOne for all saturations. value_range - [in] range of values. Use ON_Interval::ZeroToOne for all values. Returns: A color generated from seed. The color for a given seed will always be the same.
|
static |
Parameters: seed - [in] hue_range - [in] range of hues. Use ON_Interval::ZeroToTwoPi for all hues. 0 = red, pi/3 = yellow, 2pi/3 = green, pi = cyan, 4pi/3 = blue, 5pi/3 = magenta, 2pi = red saturation_range - [in] range of saturations. Use ON_Interval::ZeroToOne for all saturations. value_range - [in] range of values. Use ON_Interval::ZeroToOne for all values. Returns: A color generated from seed. The color for a given seed will always be the same.
int ON_Color::Red | ( | ) | const |
( 0 to 255 )
double ON_Color::Saturation | ( | ) | const |
Returns 0.0 (gray) to 1.0 (saturated)
void ON_Color::SetAlpha | ( | int | alpha | ) |
alpha | alpha in range 0 to 255 (0 = opaque, 255 = transparent) |
void ON_Color::SetFractionalAlpha | ( | double | alpha | ) |
alpha | alpha in range 0.0 to 1.0 (0.0 = opaque, 1.0 = transparent) |
void ON_Color::SetFractionalRGB | ( | double | red, |
double | green, | ||
double | blue | ||
) |
red | red in range 0.0 to 1.0 |
green | green in range 0.0 to 1.0 |
blue | blue in range 0.0 to 1.0 |
void ON_Color::SetFractionalRGBA | ( | double | red, |
double | green, | ||
double | blue, | ||
double | alpha | ||
) |
input args
red | red in range 0.0 to 1.0 |
green | green in range 0.0 to 1.0 |
blue | blue in range 0.0 to 1.0 |
alpha | alpha in range 0.0 to 1.0 (0.0 = opaque, 1.0 = transparent) |
void ON_Color::SetHSV | ( | double | h, |
double | s, | ||
double | v | ||
) |
Specify a color using HSV (hue, saturation, value). If h, s or v are not in the open interval (ON_UNSET_FLOAT,ON_UNSET_POSITIVE_FLOAT), then this color is set to ON_Color::UnsetColor.
h | hue in radians 0 = red, pi/3 = yellow, 2pi/3 = green, pi = cyan, 4pi/3 = blue, 5pi/3 = magenta, 2pi = red |
s | satuation 0.0 = gray, 1.0 = saturated |
v | value 0=black, 1.0 = bright |
summary> Formats used by ON_Color::ToText() and ON_Color::ToString(). /summary>
void ON_Color::SetRGB | ( | int | red, |
int | green, | ||
int | blue | ||
) |
red | red in range 0 to 255 |
green | green in range 0 to 255 |
blue | blue in range 0 to 255 |
void ON_Color::SetRGBA | ( | int | red, |
int | green, | ||
int | blue, | ||
int | alpha | ||
) |
red | red in range 0 to 255 |
green | green in range 0 to 255 |
blue | blue in range 0 to 255 |
alpha | alpha in range 0 to 255 (0 = opaque, 255 = transparent) |
const ON_wString ON_Color::ToString | ( | ON_Color::TextFormat | format, |
wchar_t | separator, | ||
bool | bFormatUnsetColor | ||
) | const |
Parameters: format - [in] separator - [in] Separates the values. 0 to use UNICODE comma. (Ignored when the format is HashRGB*.) character to separate numbers (unicode code point - UTF-16 surrogate pairs not supported) pass 0 for default. bFormatUnsetColor - [in] If true, ON_Color::UnsetColor will return "UnsetColor". Otherwise ON_Color::UnsetColor will return the empty string.
const ON_wString ON_Color::ToString | ( | ON_Color::TextFormat | format, |
wchar_t | separator, | ||
bool | bFormatUnsetColor, | ||
class ON_TextLog & | ignored_parameter | ||
) | const |
MISTAKE - BUT IT SNUCK INTO THE SDK - IGNORE
void ON_Color::ToText | ( | ON_Color::TextFormat | format, |
wchar_t | separator, | ||
bool | bFormatUnsetColor, | ||
class ON_TextLog & | text_log | ||
) | const |
Parameters: format - [in] If format is ON_Color::TextFormat::Unset, then text_log.ColorFormat is used. separator - [in] 0 to use UNICODE comma. (Ignored when the format is HashRGB*.) character to separate numbers (unicode code point - UTF-16 surrogate pairs not supported) pass 0 for default. bFormatUnsetColor - [in] If true, ON_Color::UnsetColor will return "UnsetColor". Otherwise ON_Color::UnsetColor will return the empty string. text_log - [in] destination of the text.
double ON_Color::Value | ( | ) | const |
Returns 0.0 (black) to 1.0 (white)
unsigned int ON_Color::WindowsRGB | ( | ) | const |
Description: Call this function when the color is needed in a Windows COLORREF format with alpha = 0; Returns A Windows COLOREF with alpha = 0.
|
static |
0x00000000u
|
static |
R = G = B = 105 (medium dark)
|
static |
R = G = B = 128 (medium)
|
static |
R = G = B = 160 (medium light)
|
static |
R = G = B = 230 (light)
|
static |
R = G = B = 250 (lightest)
unsigned int ON_Color::m_color = 0 |
On little endian (Intel) computers, m_color has the same byte order as Windows COLORREF values. On little endian computers, m_color = 0xaabbggrr as an unsigned int value. On big endian computers, m_color = 0xrrggbbaa as an unsigned int value rr = red component 0-255 gg = green component 0-255 bb = blue component 0-255 aa = alpha 0-255. 0 means opaque, 255 means transparent.
unsigned char ON_Color::m_RGBA[4] |
m_colorComponent is a 4 unsigned byte array in RGBA order red component = m_RGBA[ON_Color::RGBA_byte::kRed] green component = m_RGBA[ON_Color::RGBA_byte::kGreen] blue component = m_RGBA[ON_Color::RGBA_byte::kBlue] alpha component = m_RGBA[ON_Color::RGBA_byte::kAlpha]
|
static |
0x00FF0000u on little endian, 0x0000FF00u on big endian
|
static |
0x00FFFF00u on little endian, 0x00FFFF00u on big endian
|
static |
0x0000BFFFu on little endian, 0xFFBF0000u on big endian
|
static |
0x0000FF00u on little endian, 0x00FF0000u on big endian
|
static |
0x00FF00FFu on little endian, 0xFF00FF00u on big endian
|
static |
0x000000FFu on little endian, 0xFF000000u on big endian
|
static |
0x0000FFFFu on little endian, 0xFFFF0000u on big endian
|
static |
0xFFFFFFFFu
|
static |
0x00FFFFFFu on little endian, 0xFFFFFF00u on big endian