API ReferenceGE Extensionsflowgraphnodesutil
Random Color
- **Node Name:** `Random Color`
Overview
- Node Name:
Random Color - Category:
repeat_instant - File:
extensions/flowgraph/nodes/util/randomColor.lua
Generates a random color each frame. Supports a "cute color" mode that produces only highly saturated, vibrant colors.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
cuteColor | bool | If true, generates only highly saturated/vibrant colors |
randomAlpha | bool | If true, also randomizes the alpha channel |
Output Pins
| Pin | Type | Description |
|---|---|---|
color | color | The generated RGBA color as {r, g, b, a} |
Internals
Key Methods
| Method | Description |
|---|---|
work() | Generates a random color each frame based on mode settings |
Color Generation Modes
Normal mode: Each RGB channel is independently randomized with math.random() (0–1).
Cute color mode: Uses HSV color space for vibrant results:
- Hue: fully random (0–1)
- Saturation: biased high -
lerp(1, 0.7, square(math.random()))- mostly near 1.0 - Value: biased high - same formula - mostly near 1.0
- Converts via
HSVtoRGB()to produce saturated, bright colors
Alpha: Set to 1 by default, or randomized (0–1) when randomAlpha is true.
How It Works
- Determines alpha: random if
randomAlphais set, otherwise 1. - If
cuteColoris enabled:- Generates random HSV with high saturation/value bias using
square(math.random())distribution. - Converts to RGB via
HSVtoRGB().
- Generates random HSV with high saturation/value bias using
- Otherwise, generates three independent random values for R, G, B.
- Outputs the color as
{r, g, b, a}.
Usage Example
-- Apply random colors to spawned vehicles:
-- [Spawn Vehicle] → [Random Color] cuteColor=true
-- → color → [Set Vehicle Color]
-- Generate random colors with varying transparency:
-- [Random Color] randomAlpha=true → color → [Set Decal Color]
-- Direct Lua equivalent for cute colors:
local r, g, b = HSVtoRGB(math.random(), lerp(1, 0.7, square(math.random())), lerp(1, 0.7, square(math.random())))Key Dependencies
HSVtoRGB()- engine function for HSV to RGB conversionlerp(),square()- math utility functions
See Also
- Route Distance (Flowgraph Node) - Related reference
- Closest Road (Flowgraph Node) - Related reference
- Custom Lua (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide