RGBA colour. More...
#include <Colour.h>
Public Member Functions | |
Colour () | |
Default constructor. More... | |
Colour (unsigned int r, unsigned int g, unsigned int b, unsigned alpha=255) | |
Construct the color from its 4 RGBA components. More... | |
Colour (const std::string &colour) | |
Construct colour from hex code. More... | |
bool | operator== (const Colour &rhs) const |
Check if a colour is the same as this colour. More... | |
bool | operator!= (const Colour &rhs) const |
Check if a colour is not the same as this colour. More... | |
Public Attributes | |
unsigned int | red = 0 |
Red component. More... | |
unsigned int | green = 0 |
Green component. More... | |
unsigned int | blue = 0 |
Blue component. More... | |
unsigned int | opacity = 255 |
Opacity. More... | |
Static Public Attributes | |
static const Colour | Black |
Black colour. More... | |
static const Colour | White |
White colour. More... | |
static const Colour | Red |
Red colour. More... | |
static const Colour | Green |
Green colour. More... | |
static const Colour | Blue |
Blue colour. More... | |
static const Colour | Yellow |
Yellow colour. More... | |
static const Colour | Orange |
Orange colour. More... | |
static const Colour | Brown |
Brown colour. More... | |
static const Colour | Maroon |
Maroon colour. More... | |
static const Colour | Indigo |
Indigo colour. More... | |
static const Colour | Cyan |
Cyan colour. More... | |
static const Colour | Magenta |
Magenta colour. More... | |
static const Colour | Purple |
Purple colour. More... | |
static const Colour | Pink |
Pink colour. More... | |
static const Colour | Grey |
Grey colour. More... | |
static const Colour | Violet |
Violet colour. More... | |
static const Colour | Turquoise |
Turquoise colour. More... | |
static const Colour | Gold |
Gold colour. More... | |
static const Colour | Silver |
Silver colour. More... | |
static const Colour | Transparent |
Transparent colour. More... | |
Related Functions | |
(Note that these are not member functions.) | |
IME_API Colour | operator+ (const Colour &left, const Colour &right) |
Add two colours together. More... | |
IME_API Colour | operator- (const Colour &left, const Colour &right) |
Subtract two colours. More... | |
IME_API Colour | operator* (const Colour &left, const Colour &right) |
Multiply/Modulate two colours together. More... | |
IME_API Colour & | operator+= (Colour &left, const Colour &right) |
Add two colours together and assign the result to the left operand. More... | |
IME_API Colour & | operator-= (Colour &left, const Colour &right) |
Subtract two colours and assign the result to the left operand. More... | |
IME_API Colour & | operator*= (Colour &left, const Colour &right) |
Multiply/Modulate two colours together and assign the result to the left operand. More... | |
ime::Colour::Colour | ( | ) |
Default constructor.
Constructs an opaque black color
ime::Colour::Colour | ( | unsigned int | r, |
unsigned int | g, | ||
unsigned int | b, | ||
unsigned | alpha = 255 |
||
) |
Construct the color from its 4 RGBA components.
r | Red component |
g | Green component |
b | Blue component |
alpha | Alpha component |
All components must be in the range [0, 255]
|
explicit |
Construct colour from hex code.
colour | The colour in hex code |
The format of the hex code is "#rrggbb" or "#rrggbbaa" where:
For the "#rrggbb" format, the alpha component is implicitly set to FF. Note that the hex colour code must begin with a '#' symbol
bool ime::Colour::operator!= | ( | const Colour & | rhs | ) | const |
Check if a colour is not the same as this colour.
rhs | Right operand |
bool ime::Colour::operator== | ( | const Colour & | rhs | ) | const |
Check if a colour is the same as this colour.
rhs | Right operand |
Multiply/Modulate two colours together.
left | Left operand |
right | Right operand |
Note that after the multiplication, components are then divided by 255 to ensure they remain in the range [0, 255]
Multiply/Modulate two colours together and assign the result to the left operand.
left | Left operand |
right | Right operand |
Note that the colours are multiplied component-wise and after the multiplication, components are then divided by 255 to ensure they remain in the range [0, 255]
Add two colours together.
left | Left operand |
right | Right operand |
Note that the component-wise sum that exceeds 255 will be clamped to 255
Add two colours together and assign the result to the left operand.
left | Left operand |
right | Right operand |
Note that the colours are added together component-wise and the component-wise sum that exceeds 255 will be clamped to 255
Subtract two colours.
left | Left operand |
right | Right operand |
Note that the component-wise subtraction that results in a negative value will be clamped to 0
Subtract two colours and assign the result to the left operand.
left | Left operand |
right | Right operand |
Note that the colours are subtracted component-wise and the component-wise subtraction that results in a negative value will be clamped to 0
|
static |
|
static |