Types/Color: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(0-255 also works)
No edit summary
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Table of red, green, blue, and alpha float values between 0 and 1.
Table of red, green, blue, and alpha float values between 0 and 1. All values are optional, default optional value for colors is 0, for alpha 1. Alternatively, values can be from 0-255, they are interpreted as such if at least one value is > 1.<br>
All values are optional, default optional value for colors is 0, for alpha 1.
Color allows the short-hand notation of passing an array of exactly 3 or 4 numbers.<br>
Alternatively, values can be from 0-255, they are interpreted as such if at least one of r,g or b is > 1.
The game usually expects colors to be in pre-multiplied form (color channels are pre-multiplied by alpha).


{|class="wikitable"
{|class="wikitable"
Line 15: Line 15:
|}
|}


=== Example ===
== Examples ==
     color = {r=1, g=0, b=0, a=0.5} -- red
     color = {r=1, g=0, b=0, a=1} -- red, full opacity
     color = {r=1, a=0.5} -- the same red, omitting 0 colors
     color = {r=1} -- the same red, omitting default values
     color = {} -- black
    color = {1, 0, 0, 1} -- also the same red
    color = {0, 0, 1} -- blue
     color = {} -- full opacity black

Revision as of 12:36, 19 August 2021

Table of red, green, blue, and alpha float values between 0 and 1. All values are optional, default optional value for colors is 0, for alpha 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.
The game usually expects colors to be in pre-multiplied form (color channels are pre-multiplied by alpha).

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 - transparency float

Examples

   color = {r=1, g=0, b=0, a=1} -- red, full opacity
   color = {r=1} -- the same red, omitting default values
   color = {1, 0, 0, 1} -- also the same red
   color = {0, 0, 1} -- blue
   color = {} -- full opacity black