| 1 |
NAME SbColor SbCol "" { color vector class } |
| 2 |
INCLUDE SbColor.h |
| 3 |
DESC { |
| 4 |
This class is used to represent an RGB color. Each component of the vector |
| 5 |
is a floating-point number between 0.0 and 1.0. There are routines to |
| 6 |
convert back and forth between RGB and HSV. |
| 7 |
\- |
| 8 |
Note that this object does not have \mCreate\. or \mDelete\. |
| 9 |
functions. It is considered a simple datatype and should be |
| 10 |
declared and/or malloc'd as a simple C struct: |
| 11 |
\b\c |
| 12 |
/* This is defined in Inventor_c/SbColor.h: */ |
| 13 |
struct SbColor \{ |
| 14 |
float rgb[3]; |
| 15 |
\}; |
| 16 |
typedef SbColor SbCol; |
| 17 |
|
| 18 |
|
| 19 |
/* This is what your code should look like: */ |
| 20 |
SbCol c1, c2; |
| 21 |
|
| 22 |
/* The next two lines show two ways to edit the color. */ |
| 23 |
c1.rgb[0] = 1.0; c1.rgb[1] = 0.0; c1.rgb[2] = 1.0; |
| 24 |
SbColSetR_G_B( c2, 1.0, 0.0, 1.0 ); |
| 25 |
\.\. |
| 26 |
NOTE: No constructors/destructor for C-api. |
| 27 |
\. |
| 28 |
} |
| 29 |
BEGIN C++ |
| 30 |
METHOD "" SbColor(const SbVec3f vec3f) {} |
| 31 |
METHOD "" SbColor(const float rgb[3]) {} |
| 32 |
METHOD "" SbColor(float r, float g, float b) { |
| 33 |
Constructors for color vector. |
| 34 |
} |
| 35 |
END |
| 36 |
METHOD setH_S_V SbColor & setHSVValue(float h, float s, float v) { |
| 37 |
Sets value of color vector from 3 HSV (Hue, Saturation, and Value) |
| 38 |
components. Value is the same as brightness of the color. |
| 39 |
} |
| 40 |
METHOD setHSV SbColor & setHSVValue(const float hsv[3]) { |
| 41 |
Sets value of color vector from array of 3 HSV components |
| 42 |
} |
| 43 |
METHOD getH_S_V void getHSVValue(float &h, float &s, float &v) const { |
| 44 |
Returns 3 individual HSV components |
| 45 |
} |
| 46 |
METHOD getHSV void getHSVValue(float hsv[3]) const { |
| 47 |
Returns an array of 3 HSV components |
| 48 |
} |
| 49 |
METHOD setPacked SbColor & setPackedValue(uint32_t rgba, float& transparency) { |
| 50 |
Sets value of color vector from an RGBA packed color value. |
| 51 |
The packed color format expressed in hexadecimal is 0xrrggbbaa, where |
| 52 |
\b |
| 53 |
rr is the red value |
| 54 |
gg is the green value |
| 55 |
bb is the blue value |
| 56 |
aa is the alpha value |
| 57 |
\. |
| 58 |
RGBA component values range from 0 to 0xFF (255). |
| 59 |
The returned transparency value is a |
| 60 |
floating point value between 0.0 (opaque) |
| 61 |
and 1.0 (completely transparent). |
| 62 |
It is derived from the alpha component of the RGBA color. |
| 63 |
} |
| 64 |
METHOD getPacked uint32_t getPackedValue(float transparency = 0.0) const { |
| 65 |
Returns an RGBA packed color value, derived from the color |
| 66 |
vector and the passed transparency value. |
| 67 |
The alpha component is set to (1.0 - transparency) * 255, |
| 68 |
resulting in a hex value between 0 and 0xFF. |
| 69 |
If transparency not specified, alpha is set to 0xFF (opaque). |
| 70 |
|
| 71 |
} |
| 72 |
BEGIN C |
| 73 |
MACRO SbColGetRGB(float array[3], SbVec3f src) {} |
| 74 |
MACRO SbColGetR_G_B(float r, float g, float b, _src) { |
| 75 |
Returns color components. |
| 76 |
} |
| 77 |
MACRO SbColSetRGB(SbVec3f dest, float src[3]) {} |
| 78 |
MACRO SbColSetR_G_B(SbVec3f dest, float r, float g, float b) { |
| 79 |
Sets the color. |
| 80 |
} |
| 81 |
MACRO SbColMult(SbVec3f clr, float s) { |
| 82 |
Multiply the color components by a scalar value. |
| 83 |
} |
| 84 |
MACRO SbColDiv(SbVec3f clr, float s) { |
| 85 |
Divide the color components by a scalar value. |
| 86 |
} |
| 87 |
MACRO SbColAdd(SbVec3f dest, SbVec3f clr1, SbVec3f clr2) { |
| 88 |
Add two colors together. |
| 89 |
} |
| 90 |
MACRO SbColSub(SbVec3f dest, SbVec3f clr1, SbVec3f clr2) { |
| 91 |
Subtract clr2 from clr1. |
| 92 |
} |
| 93 |
ALSO { SbVec3f } |
| 94 |
|