Types/Color: Difference between revisions
Jump to navigation
Jump to search
(re-organized description, linked to Types/BlendMode) |
m (indicate permitted/optional nil) |
||
Line 1: | Line 1: | ||
Table of red, green, blue, and alpha (opacity) float values between 0 and 1. Alternatively, values can be from 0-255, they are interpreted as such if at least one value is > 1. Color allows the short-hand notation of passing an array of exactly 3 or 4 numbers.<br> | Table of red, green, blue, and alpha (opacity) float values between 0 and 1. Alternatively, values can be from 0-255, they are interpreted as such if at least one value is > 1. Color allows the short-hand notation of passing an array of exactly 3 or 4 numbers.<br> | ||
When color is nil, the default is {1, 1, 1, 1}, opaque white, or, as a tint, original color brightness and original opacity. When there is a table, all values are optional. The default optional value for colors is 0, for alpha, 1 (fully opaque). | When color is permitted nil, the default is {1, 1, 1, 1}, opaque white, or, as a tint, original color brightness and original opacity. When there is a table, all values are optional. The default optional value for colors is 0, for alpha, 1 (fully opaque). | ||
The game usually expects colors to be in pre-multiplied form (color channels are pre-multiplied by alpha). See [[Types/BlendMode]]. | The game usually expects colors to be in pre-multiplied form (color channels are pre-multiplied by alpha). See [[Types/BlendMode]]. | ||
Revision as of 22:21, 3 August 2021
Table of red, green, blue, and alpha (opacity) float values between 0 and 1. Alternatively, values can be from 0-255, they are interpreted as such if at least one value is > 1. Color allows the short-hand notation of passing an array of exactly 3 or 4 numbers.
When color is permitted nil, the default is {1, 1, 1, 1}, opaque white, or, as a tint, original color brightness and original opacity. When there is a table, all values are optional. The default optional value for colors is 0, for alpha, 1 (fully opaque). The game usually expects colors to be in pre-multiplied form (color channels are pre-multiplied by alpha). See Types/BlendMode.
name | meaning | type |
---|---|---|
r | [optional, default 0] red value | float |
g | [optional, default 0] green value | float |
b | [optional, default 0] blue value | float |
a | [optional, default 1] alpha value - opacity | float |
Examples
color = {r=1, g=0, b=0, a=0.5} -- red color = {r=1, a=0.5} -- the same red, omitting 0 colors color = {1, 0, 0, 0.5} -- also the same red color = {0, 0, 1} -- blue color = {} -- black