Bare Metal Programming Tool Kit
|
a color (in the 3 * 8 bit RGB format + transparency) More...
#include <graphics.h>
Public Member Functions | |
color (int r, int g, int b, bool t=0) | |
constructs a color object from its three components | |
color (unsigned int rgb=0) | |
constructs a color from a three-byte value | |
unsigned int | rgb15_get (void) const |
the color in RGB15 (NintendoDS) format | |
bool | is_transparent () const |
transparency indicator | |
unsigned char | red_get () const |
return the red component | |
unsigned char | green_get () const |
return the green component | |
unsigned char | blue_get () const |
return the blue component | |
color | operator+ (const color c) const |
adds two colors; addition works towards white | |
const color & | operator+= (const color c) |
adds a color to an existing color | |
color | operator+ (void) const |
returns a color unmodified | |
color | operator- (const color c) const |
subtracts two colors; subtraction works towards black | |
color & | operator-= (const color c) |
subtracts a color from an existing color | |
color | operator- (void) const |
returns the negative of a color | |
color | operator/ (unsigned int n) const |
divides a color by an integer; division works towards black | |
color & | operator/= (unsigned int n) |
divides an exiting color by an integer | |
color | operator* (unsigned int n) const |
muliplies a color by an integer; multiplication works towards white | |
color & | operator*= (unsigned int n) |
multiplies an existing color by an integer | |
bool | operator== (const color c) const |
reports whether two colors are equal | |
bool | operator!= (const color c) const |
reports whether two colors are unequal | |
color | mixed_with (const color c) const |
returns the mix of the current color and the argument | |
Static Public Member Functions | |
static color | black () |
some basic colors | |
static color | white () |
... | |
static color | red () |
... | |
static color | green () |
... | |
static color | blue () |
... | |
static color | gray () |
... | |
static color | yellow () |
... | |
static color | cyan () |
... | |
static color | magenta () |
... | |
static color | transparent () |
... | |
static color | violet () |
... | |
static color | sienna () |
... | |
static color | purple () |
... | |
static color | pink () |
... | |
static color | silver () |
... | |
static color | brown () |
... | |
static color | salmon () |
... | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const color c) |
print a color | |
a color (in the 3 * 8 bit RGB format + transparency)
A color is represented by three 8-bit values (0..255) for the red, green and blue components, and an additional boolean flag to indicate transparency (in which case the rgb values are irrelevant). Transparency is recessive: when a transparent color is combined with a non-transparent color the result is a non-transparent color.
A color can be constructed from is three components, or from a 3-byte value (as is commonly used in for instance HTML). Two colors can be added or subtracted, or be compared for equality. A color can be multiplied or divided by an integer.
For debugging, a << operator is provided to print a color.
Static methods are provided that return some basic colors, including tranparent. (These static methods instead of constants to avoid global initialization order problems.)
This color format is emissive: when colors are added (or multiplied by an integer >1), they add up towards white. Likewise subtracting works towards black.
A color fits in a single (32 bits) word. It has no references to other objects.
Definition at line 258 of file graphics.h.
|
inline |
constructs a color object from its three components
You can also supply the transparency flag, but better use the color::transparent constant.
Note that the arguments are integers, but they are clipped to the 0..255 range by the constructor.
Definition at line 278 of file graphics.h.
|
inline |
constructs a color from a three-byte value
For instance, color( 0xFF00FF ) is magenta.
Definition at line 287 of file graphics.h.
|
inlinestatic |
some basic colors
These static member functions return some common colors. These are not plain constants to avoid the static initialisation order problem: inline_font objects would have a problem with the black and white parameters for their drawable subpart. ...
Definition at line 421 of file graphics.h.
|
inline |
return the blue component
The returned component is relevant only when the color is not transparent.
Definition at line 323 of file graphics.h.
|
inline |
return the green component
The returned component is relevant only when the color is not transparent.
Definition at line 317 of file graphics.h.
|
inline |
transparency indicator
When a color is transparent its colors are irrelevant.
Definition at line 305 of file graphics.h.
|
inline |
return the red component
The returned component is relevant only when the color is not transparent.
Definition at line 311 of file graphics.h.
|
related |
print a color
This operator prints a color, either as "(transparent )", or in the (%02X,%02X,%02X) format.