CSD462 Library Documentation  1.0
15-462/15-662: Computer Graphics (Fall 2015)
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CSD462::Color Class Reference

Encodes a color via additive red, green, and blue chanel values. More...

#include <color.h>

Collaboration diagram for CSD462::Color:

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
 

Detailed Description

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].

Constructor & Destructor Documentation

CSD462::Color::Color ( float  r = 0,
float  g = 0,
float  b = 0,
float  a = 1.0 
)
inline

Constructor.

Initialize from component values. By default, alpha is initialized to 1.

Parameters
rValue of the red chanel.
gValue of the green chanel.
bValue of the blue chanel.
aValue of the alpha chanel.
CSD462::Color::Color ( const unsigned char *  arr)

Constructor.

Initialize from array of 8-bit component values (RGB only).

Parameters
arrArray containing component values.

Member Function Documentation

Color CSD462::Color::fromHex ( const char *  s)
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).

Returns
Color constructed from the input hex encoding.
string CSD462::Color::toHex ( void  ) const

Returns a hexadecimal string rrggbb encoding this color.

Returns
the hexadecimal encoding of the color.

The documentation for this class was generated from the following files: