Skip to main content

RGB/RGBA colour expressions

Shared colour constructors, alpha and channel array conversion

Native libraries, desktop scripts and browser main/Worker hosts share the evaluator.

ExpressionArguments and result
['rgb', r, g, b]Three finite channels in 0–255; alpha 1
['rgba', r, g, b, a]RGB as above; alpha in 0–1
['to-rgba', color]Four numeric values: RGB in 0–255 and alpha in 0–1
map.setPaintProperty('points', 'circle-color', [
  'rgba', ['get', 'red'], 64, 128, 0.25
]);
await map.sqs.flush({ render: true });

Constructors currently return CSS rgba strings, usable through let/var/case, properties and ordinary colour paint. Direct to-rgba conversion of these strings preserves floating-point channels and alpha. Other CSS forms use the existing byte parser, so alpha can be quantized to 1/255. GPU colours also use byte channels. typeof still reports string; there is no distinct Color value or claim of full MapLibre type compatibility. LAB/HCL interpolation remains separate work.

Invalid arity/static types reject before mutation. Invalid runtime channels/CSS use existing paint defaults and warnings. Existing evaluation budgets remain. See command confirmation for recovery after a failed command watermark.

The complete HTML example includes four controls, all handlers, data and attribution. The shared script runs in hosts supporting these common interfaces.

Syntax follows the public MapLibre colour expression specification; SqsMap implements its own evaluator. Mobile devices, Windows/macOS and formal releases are recorded separately.