25 #include "generic/range_value.h"
33 r(1.0), g(1.0), b(1.0), a(1.0) {}
35 static Colour from_bytes(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
36 return Colour(
float(r) / 255.0f,
float(g) / 255.0f,
float(b) / 255.0f,
float(a) / 255.0f);
41 Colour(
const float* buf, std::size_t count):
42 r(0), g(0), b(0), a(1) {
57 Colour(
float r,
float g,
float b,
float a):
58 r(r), g(g), b(b), a(a) {}
60 Colour operator*(
const float rhs)
const {
61 return Colour(r * rhs, g * rhs, b * rhs, a * rhs);
64 Colour operator*=(
const float rhs) {
70 return Colour(r - rhs.r, g - rhs.g, b - rhs.b, a - rhs.a);
79 return Colour(r + rhs.r, g + rhs.g, b + rhs.b, a + rhs.a);
87 bool operator==(
const Colour& rhs)
const {
88 return this->r == rhs.r && this->g == rhs.g && this->b == rhs.b && this->a == rhs.a;
91 bool operator!=(
const Colour& rhs)
const {
92 return this->r != rhs.r || this->g != rhs.g || this->b != rhs.b || this->a != rhs.a;
95 bool operator<(
const Colour& rhs)
const {
98 }
else if (r == rhs.r) {
101 }
else if(g == rhs.g) {
104 }
else if(b == rhs.b) {
118 std::string to_hex_string()
const;
119 static Colour from_hex_string(
const std::string& hex_string);
121 static const Colour BLACK;
123 static const Colour WHITE;
125 static const Colour GREEN;
127 static const Colour YELLOW;
128 static const Colour PURPLE;
129 static const Colour TURQUOISE;
145 bool operator==(
const Colour& rhs)
const;
147 bool operator!=(
const Colour& rhs)
const {
148 return !(*
this == rhs);
184 std::ostream& operator<<(std::ostream& stream,
const Colour& c);