20 std::tr1::uint32_t rep;
21 #ifdef GOSU_IS_LITTLE_ENDIAN
22 enum { RED_OFFSET = 0, GREEN_OFFSET = 8, BLUE_OFFSET = 16, ALPHA_OFFSET = 24 };
24 enum { RED_OFFSET = 24, GREEN_OFFSET = 16, BLUE_OFFSET = 8, ALPHA_OFFSET = 0 };
39 *
this =
Color((argb >> 24) & 0xff, (argb >> 16) & 0xff,
40 (argb >> 8) & 0xff, (argb >> 0) & 0xff);
45 *
this =
Color(0xff, red, green, blue);
50 rep = (alpha << ALPHA_OFFSET) | (red << RED_OFFSET) |
51 (green << GREEN_OFFSET) | (blue << BLUE_OFFSET);
63 return static_cast<Channel>(rep >> RED_OFFSET);
68 return static_cast<Channel>(rep >> GREEN_OFFSET);
73 return static_cast<Channel>(rep >> BLUE_OFFSET);
78 return static_cast<Channel>(rep >> ALPHA_OFFSET);
83 rep &= ~(0xff << RED_OFFSET);
84 rep |= value << RED_OFFSET;
89 rep &= ~(0xff << GREEN_OFFSET);
90 rep |= value << GREEN_OFFSET;
95 rep &= ~(0xff << BLUE_OFFSET);
96 rep |= value << BLUE_OFFSET;
101 rep &= ~(0xff << ALPHA_OFFSET);
102 rep |= value << ALPHA_OFFSET;
118 double value()
const;
124 std::tr1::uint32_t
argb()
const
130 std::tr1::uint32_t
bgr()
const
136 std::tr1::uint32_t
abgr()
const
142 std::tr1::uint32_t
gl()
const
164 return a.
gl() < b.
gl();
169 return a.
gl() == b.
gl();
174 return a.
gl() != b.
gl();
181 Color
interpolate(Color a, Color b,
double weight = 0.5);
Includes all parts of C++03 (TR1) that are relevant for Gosu.
GOSU_DEPRECATED const Color aqua(0xff00ffff)
GOSU_DEPRECATED const Color white(0xffffffff)
GOSU_DEPRECATED const Color green(0xff00ff00)
GOSU_DEPRECATED const Color none(0x00000000)
GOSU_DEPRECATED const Color blue(0xff0000ff)
Color()
The default constructor does not initialize the color to any value.
Represents an RGBA color value with 8 bits for each channel.
static const Color YELLOW
std::tr1::uint32_t abgr() const
Returns the color in 0xaabbggrr representation.
static Color fromHSV(double h, double s, double v)
Constructs a color from the given hue/saturation/value triple.
void setBlue(Channel value)
double saturation() const
Returns the saturation of the color, in the range of 0..1.
void setGreen(Channel value)
double value() const
Returns the value (brightness) of the color, in the range of 0..1.
std::tr1::uint32_t bgr() const
Returns the color in 0x00bbggrr representation. Useful for Win32 programming.
void setSaturation(double s)
Changes the current color so saturation() will return s.
std::tr1::uint8_t Channel
GOSU_DEPRECATED const Color cyan(0xff00ffff)
GOSU_DEPRECATED const Color yellow(0xffffff00)
void setAlpha(Channel value)
bool operator!=(Color a, Color b)
GOSU_DEPRECATED const Color fuchsia(0xffff00ff)
std::tr1::uint32_t gl() const
Returns the internal representation of the color (RGBA in memory).
Color interpolate(Color a, Color b, double weight=0.5)
Interpolates linearly between two colors, with a given weight towards the second color.
GOSU_DEPRECATED const Color gray(0xff808080)
Color(unsigned argb)
Conversion constructor for literals of the form 0xaarrggbb.
double hue() const
Returns the hue of the color, in the usual range of 0..360.
bool operator==(Color a, Color b)
static Color fromAHSV(Channel alpha, double h, double s, double v)
Color(Channel alpha, Channel red, Channel green, Channel blue)
static const unsigned GL_FORMAT
std::tr1::uint32_t argb() const
Returns the color in 0xaarrggbb representation.
void setHue(double h)
Changes the current color so hue() will return h.
Color(Channel red, Channel green, Channel blue)
GOSU_DEPRECATED const Color red(0xffff0000)
GOSU_DEPRECATED const Color black(0xff000000)
Color multiply(Color a, Color b)
Combines two colors as if their channels were mapped to the 0..1 range and then multiplied with each ...
void setValue(double v)
Changes the current color so value() will return v.
void setRed(Channel value)
static const Color FUCHSIA
bool operator<(Color a, Color b)