rgba
result = rgb(r, g, b)
Input: r, g, b · Output: result
What it is
Builds a colour from channel numbers: r, g, b (and, for rgba, a fourth channel a) — a fractional 0–1 fourth channel is an opacity, a whole number 0–255 is a byte value like the other three. For channels that are computed rather than typed literally.
Overloads
rgba(r, g, b, a) reads its fourth channel a two different ways depending on its own magnitude, so the same call can be written either the "raw byte" way or the CSS "opacity fraction" way and land on the same colour.
2 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.
| Code | Input | Output | Description |
result = rgb(r, g, b) | r numbernot documented yetg numbernot documented yetb numbernot documented yet | result string | Written as a whole number sharing the other three channels' 0–255 range, a is read as a raw alpha byte. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
print(rgba(255, 0, 0, 128)) # "#ff000080" -- half-transparent red, byte alpha
#ff000080
| Code | Input | Output | Description |
result = rgb(r, g, b) | r numbernot documented yetg numbernot documented yetb numbernot documented yet | result string | Written as a number 0–1 instead, a is read as an opacity fraction — the CSS convention — so 0.5 here lands on the exact same byte as 128 above. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
print(rgba(255, 0, 0, 0.5)) # "#ff000080" -- the same colour, from the CSS-style opacity fraction
#ff000080
See also
rgb — documented in the same entry.