2.6 KiB
2.6 KiB
Display -- Color
Source: build/generated/display/color.h (generated at build time)
Overview
color.h is a generated header. It is not hand-edited -- the source
lives in the CMake generator that produces it from platform configuration.
Include it via "display/color.h".
Types
typedef float_t colorchannelf_t; // float channel [0.0, 1.0]
typedef uint8_t colorchannel8_t; // 8-bit channel [0, 255]
typedef struct { colorchannelf_t r, g, b; } color3f_t;
typedef struct { colorchannelf_t r, g, b, a; } color4f_t;
typedef struct { colorchannel8_t r, g, b; } color3b_t;
typedef struct { colorchannel8_t r, g, b, a; } color4b_t;
typedef color4b_t color_t; // default: RGBA uint8
color_t is always color4b_t -- four uint8_t channels.
Most engine APIs (text rendering, UI, mesh vertices) take color_t.
Constructors
color3f(r, g, b) // float RGB
color4f(r, g, b, a) // float RGBA
color3b(r, g, b) // uint8 RGB
color4b(r, g, b, a) // uint8 RGBA
color(r, g, b, a) // alias for color4b
colorHex(0xRRGGBBAA) // unpack 32-bit hex into color4b
Predefined constants
Each named colour comes in four variants: _4B (uint8 RGBA, default),
_3B (uint8 RGB), _4F (float RGBA), _3F (float RGB). The bare
name (e.g. COLOR_BLACK) always resolves to the _4B variant.
| Constant | RGBA (uint8) |
|---|---|
COLOR_BLACK |
0, 0, 0, 255 |
COLOR_WHITE |
255, 255, 255, 255 |
COLOR_RED |
255, 0, 0, 255 |
COLOR_GREEN |
0, 255, 0, 255 |
COLOR_BLUE |
0, 0, 255, 255 |
COLOR_YELLOW |
255, 255, 0, 255 |
COLOR_CYAN |
0, 255, 255, 255 |
COLOR_MAGENTA |
255, 0, 255, 255 |
COLOR_ORANGE |
255, 165, 0, 255 |
COLOR_PURPLE |
127, 0, 127, 255 |
COLOR_GRAY |
127, 127, 127, 255 |
COLOR_LIGHT_GRAY |
191, 191, 191, 255 |
COLOR_DARK_GRAY |
63, 63, 63, 255 |
COLOR_BROWN |
153, 102, 51, 255 |
COLOR_PINK |
255, 191, 204, 255 |
COLOR_LIME |
191, 255, 0, 255 |
COLOR_NAVY |
0, 0, 127, 255 |
COLOR_TEAL |
0, 127, 127, 255 |
COLOR_CORNFLOWER_BLUE |
99, 147, 237, 255 |
COLOR_TRANSPARENT |
0, 0, 0, 0 |
COLOR_TRANSPARENT_WHITE |
255, 255, 255, 0 |
COLOR_TRANSPARENT_BLACK |
0, 0, 0, 0 |
Notes
color_tuses premultiplied-friendlyuint8_tchannels for compatibility with both OpenGL texture uploads and GX on Dolphin.- For shader uniforms that expect float colours, convert manually:
(float_t)col.r / 255.0fetc. - The
COLOR_SCRIPTmacro is a C string containing the JS Color class static methods. It is concatenated into the embedded JS runtime during module init (see.claude/script.md).