#if !defined(BRL_COLOR_HPP)
#define BRL_COLOR_HPP
/*+----------------------------------------------------------------------------
Ben Landon
CSCI E-235
Color
This is a simple class that hangs onto RGBA values.
There are also a few named colors (e.g. "blue") that
are generally useful.
*/
class Color
{
private:
float m_red;
float m_green;
float m_blue;
float m_alpha;
public:
Color (void);
Color (const Color& color);
Color (float r, float g, float b);
Color (float r, float g, float b, float a);
~Color ();
const Color& operator= (const Color& color);
float red (void) const { return m_red; }
float green (void) const {return m_green; }
float blue (void) const {return m_blue; }
float alpha (void) const {return m_alpha; }
float r (void) const {return this->red(); }
float g (void) const {return this->green(); }
float b (void) const {return this->blue(); }
float a (void) const {return this->alpha(); }
void set (float r, float g, float b, float a = 1.0f);
void set_from_array (const float* array, int size);
// Return the sum of the red green and blue channels
// multiplied by opacity. This gives the brightness
// of a color.
float sum (void) { return m_alpha * (m_red + m_green + m_blue); }
// Set as the current color in OpenGL.
void make_current (void) const;
// Return the color data in a float array.
void to_float_array (float *array, int size) const;
static void set_current (const Color& color);
};
extern const Color cyan;
extern const Color yellow;
extern const Color blue;
extern const Color red;
extern const Color magenta;
extern const Color green;
extern const Color black;
extern const Color white;
extern const Color gray;
#endif