Skip to content

Colour

Generated from engine/render/colour.h at 862e08b. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.

Browse the render module

#include "engine/render/colour.h" · namespace labrador

struct Colour

An RGBA colour, each channel clamped to [0, 1].

NOT IN MattMath, whose job is shapes and vectors and which is documented as depending on nothing. A colour is not geometry - it is what a renderer tints a sprite with - so it lives here, and so does the palette.

float r = 0.0f;
float g = 0.0f;
float b = 0.0f;
float a = 0.0f;
constexpr Colour() = default;
constexpr Colour(const Colour&) = default;
constexpr Colour(float r, float g, float b);
constexpr Colour(float r, float g, float b, float a);
constexpr Colour(int r, int g, int b, int a = 255);
explicit Colour(const std::string& hex);
Colour& operator=(const Colour&) = default;
bool operator==(const Colour& other) const;
bool operator!=(const Colour& other) const;

operator+= · operator-= · operator*= · operator/=

Section titled “operator+= · operator-= · operator*= · operator/=”
Colour& operator+=(const Colour& other);
Colour& operator-=(const Colour& other);
Colour& operator*=(const Colour& other);
Colour& operator*=(float f);
Colour& operator/=(const Colour& other);
Colour& operator/=(float f);
void set_from_hex(const std::string& hex);

Assigns the whole colour from hex: RRGGBB or RRGGBBAA, hex digits of either case and no leading '#'. Any other string makes it opaque black. There are no per-channel accessors or setters beside this: the fields are the interface, and a whole colour is assigned, not four channels.

void saturate(float amount);

Scales each channel's distance from the colour's luminance: 0 is fully grey, 1 leaves it alone, above 1 saturates. One function with a documented range: desaturating is an amount below 1.

void brighten(float amount);
void darken(float amount);
void invert();
void make_opaque();
void make_transparent();
void clamp_colours();

alice_blue · antique_white · aqua · aquamarine · azure · beige · bisque · black · blanched_almond · blue · blue_violet · brown · burlywood · cadet_blue · chartreuse · chocolate · coral · cornflower_blue · cornsilk · crimson · cyan · dark_blue · dark_cyan · dark_goldenrod · dark_gray · dark_green · dark_grey · dark_khaki · dark_magenta · dark_olive_green · dark_orange · dark_orchid · dark_red · dark_salmon · dark_sea_green · dark_slate_blue · dark_slate_gray · dark_slate_grey · dark_turquoise · dark_violet · deep_pink · deep_sky_blue · dim_gray · dim_grey · dodger_blue · fire_brick · floral_white · forest_green · fuchsia · gainsboro · ghost_white · gold · goldenrod · gray · green · green_yellow · grey · honeydew · hot_pink · indian_red · indigo · ivory · khaki · lavender · lavender_blush · lawn_green · lemon_chiffon · light_blue · light_coral · light_cyan · light_goldenrod_yellow · light_gray · light_green · light_grey · light_pink · light_salmon · light_sea_green · light_sky_blue · light_slate_gray · light_slate_grey · light_steel_blue · light_yellow · lime · lime_green · linen · magenta · maroon · medium_aquamarine · medium_blue · medium_orchid · medium_purple · medium_sea_green · medium_slate_blue · medium_spring_green · medium_turquoise · medium_violet_red · midnight_blue · mint_cream · misty_rose · moccasin · navajo_white · navy · old_lace · olive · olive_drab · orange · orange_red · orchid · pale_goldenrod · pale_green · pale_turquoise · pale_violet_red · papaya_whip · peach_puff · peru · pink · plum · powder_blue · purple · rebecca_purple · red · rosy_brown · royal_blue · saddle_brown · salmon · sandy_brown · sea_green · seashell · sienna · silver · sky_blue · slate_blue · slate_gray · slate_grey · snow · spring_green · steel_blue · tan · teal · thistle · tomato · turquoise · violet · wheat · white · white_smoke · yellow · yellow_green

Section titled “alice_blue · antique_white · aqua · aquamarine · azure · beige · bisque · black · blanched_almond · blue · blue_violet · brown · burlywood · cadet_blue · chartreuse · chocolate · coral · cornflower_blue · cornsilk · crimson · cyan · dark_blue · dark_cyan · dark_goldenrod · dark_gray · dark_green · dark_grey · dark_khaki · dark_magenta · dark_olive_green · dark_orange · dark_orchid · dark_red · dark_salmon · dark_sea_green · dark_slate_blue · dark_slate_gray · dark_slate_grey · dark_turquoise · dark_violet · deep_pink · deep_sky_blue · dim_gray · dim_grey · dodger_blue · fire_brick · floral_white · forest_green · fuchsia · gainsboro · ghost_white · gold · goldenrod · gray · green · green_yellow · grey · honeydew · hot_pink · indian_red · indigo · ivory · khaki · lavender · lavender_blush · lawn_green · lemon_chiffon · light_blue · light_coral · light_cyan · light_goldenrod_yellow · light_gray · light_green · light_grey · light_pink · light_salmon · light_sea_green · light_sky_blue · light_slate_gray · light_slate_grey · light_steel_blue · light_yellow · lime · lime_green · linen · magenta · maroon · medium_aquamarine · medium_blue · medium_orchid · medium_purple · medium_sea_green · medium_slate_blue · medium_spring_green · medium_turquoise · medium_violet_red · midnight_blue · mint_cream · misty_rose · moccasin · navajo_white · navy · old_lace · olive · olive_drab · orange · orange_red · orchid · pale_goldenrod · pale_green · pale_turquoise · pale_violet_red · papaya_whip · peach_puff · peru · pink · plum · powder_blue · purple · rebecca_purple · red · rosy_brown · royal_blue · saddle_brown · salmon · sandy_brown · sea_green · seashell · sienna · silver · sky_blue · slate_blue · slate_gray · slate_grey · snow · spring_green · steel_blue · tan · teal · thistle · tomato · turquoise · violet · wheat · white · white_smoke · yellow · yellow_green”
static const Colour alice_blue;
static const Colour antique_white;
static const Colour aqua;
static const Colour aquamarine;
static const Colour azure;
static const Colour beige;
static const Colour bisque;
static const Colour black;
static const Colour blanched_almond;
static const Colour blue;
static const Colour blue_violet;
static const Colour brown;
static const Colour burlywood;
static const Colour cadet_blue;
static const Colour chartreuse;
static const Colour chocolate;
static const Colour coral;
static const Colour cornflower_blue;
static const Colour cornsilk;
static const Colour crimson;
static const Colour cyan;
static const Colour dark_blue;
static const Colour dark_cyan;
static const Colour dark_goldenrod;
static const Colour dark_gray;
static const Colour dark_green;
static const Colour dark_grey;
static const Colour dark_khaki;
static const Colour dark_magenta;
static const Colour dark_olive_green;
static const Colour dark_orange;
static const Colour dark_orchid;
static const Colour dark_red;
static const Colour dark_salmon;
static const Colour dark_sea_green;
static const Colour dark_slate_blue;
static const Colour dark_slate_gray;
static const Colour dark_slate_grey;
static const Colour dark_turquoise;
static const Colour dark_violet;
static const Colour deep_pink;
static const Colour deep_sky_blue;
static const Colour dim_gray;
static const Colour dim_grey;
static const Colour dodger_blue;
static const Colour fire_brick;
static const Colour floral_white;
static const Colour forest_green;
static const Colour fuchsia;
static const Colour gainsboro;
static const Colour ghost_white;
static const Colour gold;
static const Colour goldenrod;
static const Colour gray;
static const Colour green;
static const Colour green_yellow;
static const Colour grey;
static const Colour honeydew;
static const Colour hot_pink;
static const Colour indian_red;
static const Colour indigo;
static const Colour ivory;
static const Colour khaki;
static const Colour lavender;
static const Colour lavender_blush;
static const Colour lawn_green;
static const Colour lemon_chiffon;
static const Colour light_blue;
static const Colour light_coral;
static const Colour light_cyan;
static const Colour light_goldenrod_yellow;
static const Colour light_gray;
static const Colour light_green;
static const Colour light_grey;
static const Colour light_pink;
static const Colour light_salmon;
static const Colour light_sea_green;
static const Colour light_sky_blue;
static const Colour light_slate_gray;
static const Colour light_slate_grey;
static const Colour light_steel_blue;
static const Colour light_yellow;
static const Colour lime;
static const Colour lime_green;
static const Colour linen;
static const Colour magenta;
static const Colour maroon;
static const Colour medium_aquamarine;
static const Colour medium_blue;
static const Colour medium_orchid;
static const Colour medium_purple;
static const Colour medium_sea_green;
static const Colour medium_slate_blue;
static const Colour medium_spring_green;
static const Colour medium_turquoise;
static const Colour medium_violet_red;
static const Colour midnight_blue;
static const Colour mint_cream;
static const Colour misty_rose;
static const Colour moccasin;
static const Colour navajo_white;
static const Colour navy;
static const Colour old_lace;
static const Colour olive;
static const Colour olive_drab;
static const Colour orange;
static const Colour orange_red;
static const Colour orchid;
static const Colour pale_goldenrod;
static const Colour pale_green;
static const Colour pale_turquoise;
static const Colour pale_violet_red;
static const Colour papaya_whip;
static const Colour peach_puff;
static const Colour peru;
static const Colour pink;
static const Colour plum;
static const Colour powder_blue;
static const Colour purple;
static const Colour rebecca_purple;
static const Colour red;
static const Colour rosy_brown;
static const Colour royal_blue;
static const Colour saddle_brown;
static const Colour salmon;
static const Colour sandy_brown;
static const Colour sea_green;
static const Colour seashell;
static const Colour sienna;
static const Colour silver;
static const Colour sky_blue;
static const Colour slate_blue;
static const Colour slate_gray;
static const Colour slate_grey;
static const Colour snow;
static const Colour spring_green;
static const Colour steel_blue;
static const Colour tan;
static const Colour teal;
static const Colour thistle;
static const Colour tomato;
static const Colour turquoise;
static const Colour violet;
static const Colour wheat;
static const Colour white;
static const Colour white_smoke;
static const Colour yellow;
static const Colour yellow_green;

The CSS named colours. Declared here and defined once in colour.cpp, constant-initialised, so there is one set however many translation units include this header.

CONVENTIONS names Colour::white as what a constant looks like.

operator+ · operator- · operator* · operator/

Section titled “operator+ · operator- · operator* · operator/”
Colour operator+ (const Colour& V1, const Colour& V2);
Colour operator- (const Colour& V1, const Colour& V2);
Colour operator* (const Colour& V1, const Colour& V2);
Colour operator* (const Colour& V, float S);
Colour operator/ (const Colour& V1, const Colour& V2);
Colour operator/ (const Colour& V, float S);
Colour operator* (float S, const Colour& V);
std::optional<Colour> colour_from_name(std::string_view name);

Looks up one of the 148 names above, spelt as content files spell them (SCREAMING_SNAKE - "DARK_SLATE_GREY" for dark_slate_grey). Returns nothing for a name that is not one of them; the caller decides whether that is a default or an error.

The files that include this header directly. A file can also reach it through another header.

Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.