36 void init(
float r,
float g,
float b) {
42 std::vector<float> convert_to_hsv()
const;
43 void convert_from_hsv(
const std::vector<float> &hsv);
45 std::vector<float> col;
46 colour_t() { init(0.5, 0.5, 0.5); }
47 colour_t(
float r,
float g,
float b) { init(r,g,b); }
48 void set(
float r,
float g,
float b) { init(r,g,b); }
49 float &operator[](
const unsigned int &idx) {
return col[idx]; }
50 const float &operator[](
const unsigned int &idx)
const {
return col[idx]; }
52 void average(
const colour_t &other) {
53 for (
unsigned int idx=0; idx<3; idx++)
54 col[idx] = 0.5 * (col[idx] + other[idx]);
56 void brighter(
float f) {
57 for (
unsigned int idx=0; idx<3; idx++)
59 for (
unsigned int idx=0; idx<3; idx++)
63 glm::vec4 to_glm()
const {
64 return glm::vec4(col[0], col[1], col[2], 1.0f);
66 colour_holder to_colour_holder()
const {
67 return colour_holder(col[0], col[1], col[2]);