|
//********************************************
// Color.h
//********************************************
// alliez@usc.edu
// Created : 10/12/97
// Modified : 09/02/98
//********************************************
#ifndef _COLOR_
#define _COLOR_
class CColor
{
private :
// Color
unsigned char m_Red;
unsigned char m_Green;
unsigned char m_Blue;
unsigned char m_Alpha;
public :
// Constructor
CColor()
{
m_Red = m_Green = m_Blue = m_Alpha = 255;
}
CColor(CColor &color)
{
m_Red = color.r();
m_Green = color.g();
m_Blue = color.b();
m_Alpha = color.a();
}
~CColor() {}
// Constructor
CColor(unsigned char grey) { Set(grey); }
CColor(unsigned char red,unsigned char green,unsigned char blue) { Set(red,green,blue); }
CColor(unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha) { Set(red,green,blue,alpha); }
// Data access
unsigned char r(void) { return m_Red; }
unsigned char g(void) { return m_Green; }
unsigned char b(void) { return m_Blue; }
unsigned char a(void) { return m_Alpha; }
// Data setting
void r(unsigned char red) { m_Red = red; }
void g(unsigned char green) { m_Green = green; }
void b(unsigned char blue) { m_Blue = blue; }
void a(unsigned char alpha) { m_Alpha = alpha; }
// Data setting
void Set(CColor &c);
void Set(unsigned char grey);
void Set(unsigned char red,unsigned char green,unsigned char blue);
void Set(unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha);
int operator==(CColor &color) { return (color.r() == m_Red) && (color.g() == m_Green) && (color.b() == m_Blue); }
int operator==(CColor *pColor) { return (pColor->r() == m_Red) && (pColor->g() == m_Green) && (pColor->b() == m_Blue); }
};
#endif // _COLOR_
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.