Color class represents an RGBA color value where each channel (r, g, b, a) is a floating-point number in the range 0 to 1. You use Color whenever you need to tint objects, set dialog backgrounds, drive visual effects, or blend between two colors over time. RollingQuest also provides a collection of pre-built static colors — like Color.red and Color.white — so you don’t have to remember the exact component values for common colors. All component properties are read-only after construction; create a new Color to change a value.
Constructors
| Signature | Description |
|---|---|
Color.new(r, g, b, a) | Creates a color with explicit red, green, blue, and alpha values. |
Color.new(r, g, b) | Creates a color with the given channels; alpha is 1 (fully opaque). |
Color.new(grayscale) | Sets R, G, and B to grayscale; alpha is 1. |
Color.new(grayscale, alpha) | Sets R, G, and B to grayscale with the given alpha. |
Color.new() | Returns a transparent black (0, 0, 0, 0). |
Instance Properties
| Property | Type | Read-only | Description |
|---|---|---|---|
r | number | Yes | The red channel (0–1). |
g | number | Yes | The green channel (0–1). |
b | number | Yes | The blue channel (0–1). |
a | number | Yes | The alpha (opacity) channel (0–1). |
grayscale | number | Yes | The perceptual grayscale value of the color. |
maxColorComponent | number | Yes | The highest value among R, G, and B. |
linear | Color | Yes | This color converted to linear color space. |
gamma | Color | Yes | This color converted to gamma color space. |
Color by integer (c[1] → R, c[2] → G, c[3] → B, c[4] → A) for both read and write access.
Static Color Constants
These pre-built colors are available without constructing anything.| Constant | RGBA |
|---|---|
Color.red | (1, 0, 0, 1) |
Color.green | (0, 1, 0, 1) |
Color.blue | (0, 0, 1, 1) |
Color.white | (1, 1, 1, 1) |
Color.black | (0, 0, 0, 1) |
Color.yellow | (1, 0.92, 0.016, 1) |
Color.cyan | (0, 1, 1, 1) |
Color.magenta | (1, 0, 1, 1) |
Color.gray | (0.5, 0.5, 0.5, 1) |
Color.grey | Alias for Color.gray. |
Color.clear | (0, 0, 0, 0) — fully transparent. |
Static Methods
lerp
Linearly interpolates between color a and color b by the clamped factor t (0 → a, 1 → b). Each channel is interpolated independently.
lerpUnclamped
Same as lerp but t is not clamped, allowing extrapolation beyond the two endpoints.
Usage Examples
Creating custom colors
Blending between two colors over time
Using a Color with the Dialog namespace
Pass aColor value as the background parameter when showing a dialog so your UI fits the scene’s mood.