Color channels are the way Geometry Dash controls the color of objects and the environment at runtime. Every channel has a numeric ID, and triggers written to that channel affect all objects using it. G.js wraps each channel in aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/g-js-api/G.js/llms.txt
Use this file to discover all available pages before exploring further.
$color instance that exposes every color-related trigger as a method, so you can drive dynamic lighting, flashing effects, and timed fades with plain JavaScript — no raw trigger dictionaries required.
For a conceptual overview see Groups, Colors & Blocks.
Creating Colors
color(id)
Creates a $color instance from a known color channel ID. G.js marks this ID as in-use so it will not be returned by unknown_c().
The GD color channel ID.
$color
unknown_c()
Allocates and returns the next free color channel ID. Use this when you need a channel but do not care about its exact number.
$color
new $color(a, specific?)
The underlying class constructor. Prefer color() and unknown_c() in everyday code; use the constructor when you need explicit control over ID allocation.
The color channel ID value.
When
true (the default), marks this ID as unavailable for future
unknown_c() allocations.$color is also a named TypeScript export for use in type annotations:
Pre-defined Color Constants
G.js exposes named constants for the special built-in GD color channels. Import them from@g-js-api/g.js/safe in safe mode; they are available globally otherwise.
| Constant | Channel |
|---|---|
BG | Background |
GROUND | Ground (layer 1) |
GROUND2 | Ground (layer 2) |
LINE | Ground line |
_3DLINE | 3D line |
OBJECT | Default object color |
MIDDLEGROUND | Middleground layer 1 |
MIDDLEGROUND_2 | Middleground layer 2 |
BLACK | Pure black channel |
WHITE | Pure white channel |
LIGHTER | Lighter color channel |
Methods
set(c, duration?, blending?)
Creates a Color trigger that sets the channel to an RGB value.
Target RGB color as a three-element array, e.g.
[255, 128, 0]. Use the rgb() helper for a named alternative.Seconds over which the color transitions to
c.When
true, enables additive blending on the color channel.copy(c, duration?, hvs?, blending?, opacity?, copy_opacity?)
Creates a Copy Color trigger that mirrors another channel, optionally with an HSV transform applied on top.
The source color channel to copy from.
Transition duration in seconds.
HSV modifier string. Use the
hsv() helper to generate this value cleanly.Enable additive blending on the destination channel.
Opacity of the copied color (0–1).
When
true, also copies the source channel’s opacity value.pulse(c, fade_in?, hold?, fade_out?, exclusive?)
Creates a Pulse trigger that temporarily overlays an RGB color onto the channel.
RGB color to pulse, e.g.
[255, 200, 100].Seconds to blend in the pulse color.
Seconds to hold the pulse color at full strength.
Seconds to fade back to the original color.
When
true, this pulse takes priority over other simultaneous pulses on the same channel.pulse_hsv(h, s, b, s_checked?, b_checked?, fade_in?, hold?, fade_out?, exclusive?)
Creates a Pulse trigger using HSV values rather than RGB.
Hue offset (-180 to 180).
Saturation value.
Brightness value.
When
true, saturation is treated as an absolute value rather than an offset.When
true, brightness is treated as an absolute value rather than an offset.Fade-in time in seconds.
Hold time in seconds.
Fade-out time in seconds.
Prioritize over simultaneous pulses on the same channel.
Helper Functions
hsv(hue, sat, bright, sat_checked?, bright_checked?)
Generates an HSV modifier string for use in copy(). The string is formatted the way GD expects it internally.
Hue offset (-180 to 180).
Saturation value.
Brightness value.
Use saturation as absolute value.
Use brightness as absolute value.
string
rgb(r, g, b)
Creates an RGB array. Equivalent to writing [r, g, b] but reads more expressively.
Red component (0–255).
Green component (0–255).
Blue component (0–255).
number[]
rgba(r, g, b, a)
Creates an RGBA array including an alpha component.
Red component (0–255).
Green component (0–255).
Blue component (0–255).
Alpha component (0–1).
number[]
color_trigger(channel, r, g, b, duration?, opacity?, blending?)
A standalone function that creates a Color trigger without needing a $color instance. Useful when you have a raw channel ID or want a one-liner.
The color channel to target.
Red value (0–255).
Green value (0–255).
Blue value (0–255).
Transition duration in seconds.
Channel opacity (0–1).
Enable additive blending.
Code examples
Color channel IDs in GD are limited. If you need many dynamic colors, use
unknown_c() to allocate them automatically and avoid accidentally reusing
channels that are already assigned to level geometry.