![]() |
Angel
A 2D Game Prototyping Engine
|
A class to encapsulate color information. More...
#include <Color.h>
Public Member Functions | |
| Color () | |
| Color (float r, float g, float b, float a=1.0f, bool clamp=true) | |
| bool | operator== (const Color &c) const |
| bool | operator!= (const Color &c) const |
| Color | operator- (const Color &c) const |
| Color | operator+ (const Color &c) const |
| Color | operator/ (float divider) const |
| Color | operator* (float scaleFactor) const |
Static Public Member Functions | |
| static Color | FromInts (int r, int g, int b, int a=255, bool clamp=true) |
| static Color | FromHexString (String hexString) |
Public Attributes | |
| float | R |
| float | G |
| float | B |
| float | A |
This class consolidates all color information into a single unit that can be easily passed around functions, manipulated, and lerped.
The four color components are public members since they are frequently accessed and there is no real reason to hide them behind accessors. They are always stored as floats and range from 0.0f to 1.0f.
Note that the common arithmetical and comparison operators are defined for this class, to make it easy to mathematically manipulate the color of your Actors.
| Color::Color | ( | ) |
| Color::Color | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float | a = 1.0f, |
||
| bool | clamp = true |
||
| ) |
A constructor to specify component values right from the start.
| r | The Red component |
| g | The Green component |
| b | The Blue component |
| a | The Alpha component |
| clamp | Whether or not to clamp the components to the range 0.0 to 1.0. Usually you want to do this (and the default reflects this case), unless you're doing some kind of nutty color math, in which case you should set this to false. |
| Color Color::FromInts | ( | int | r, |
| int | g, | ||
| int | b, | ||
| int | a = 255, |
||
| bool | clamp = true |
||
| ) | [static] |
A function to specify colors as integers from 0 to 255. Useful if you've got a color picker you like that gives you values in this range.
Note that internally the numbers are converted to floats from 0 to 1.
| r | The Red component |
| g | The Green component |
| b | The Blue component |
| a | The Alpha component |
| clamp | Whether or not to clamp the components to the range 0.0 to 1.0. Usually you want to do this (and the default reflects this case), unless you're doing some kind of nutty color math, in which case you should set this to false. |
| Color Color::FromHexString | ( | String | hexString | ) | [static] |
| float Color::A |


1.7.5.1