|
CMU462 Library Documentation
1.0
15-462/15-662: Computer Graphics (Fall 2015)
|
Encodes a color via additive red, green, and blue chanel values. More...
#include <color.h>
Public Member Functions | |
| Color (float r=0, float g=0, float b=0, float a=1.0) | |
| Constructor. More... | |
| Color (const unsigned char *arr) | |
| Constructor. More... | |
| std::string | toHex () const |
| Returns a hexadecimal string rrggbb encoding this color. More... | |
Static Public Member Functions | |
| static Color | fromHex (const char *s) |
| Construct a Color object from a hexadecimal (8-bit per component) ASCII string. More... | |
Public Attributes | |
| float | r |
| value of red chanel | |
| float | g |
| value of green chanel | |
| float | b |
| value of blue chanel | |
| float | a |
| value of alpha chanel | |
Encodes a color via additive red, green, and blue chanel values.
Each color chanel value is in the range [0,1]. The alpha value defines the transparency of the color and is also in [0,1].
|
inline |
Constructor.
Initialize from component values. By default, alpha is initialized to 1.
| r | Value of the red chanel. |
| g | Value of the green chanel. |
| b | Value of the blue chanel. |
| a | Value of the alpha chanel. |
| CMU462::Color::Color | ( | const unsigned char * | arr | ) |
Constructor.
Initialize from array of 8-bit component values (RGB only).
| arr | Array containing component values. |
|
static |
Construct a Color object from a hexadecimal (8-bit per component) ASCII string.
Since hexademical strings are typically not used to encode alpha values, the alpha is set to 1 (opaque) by default. This method also accepts the string "none", in which case it returns a color value with alpha zero (transparent).
| string CMU462::Color::toHex | ( | void | ) | const |
Returns a hexadecimal string rrggbb encoding this color.
1.8.9.1