Types/Color: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Created page with "Table of red, green, blue, and [optional] alpha float values between 0 and 1. {|class="wikitable" ! name !! meaning !! type |- | r || red value || float |- | g...")
 
(Updated styling of prototype doc migration note)
 
(20 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Table of red, green, blue, and [optional] alpha float values between 0 and 1.
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/types/Color.html https://lua-api.factorio.com/latest/types/Color.html]
 
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
 
 
 
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>
Color allows the short-hand notation of passing an array of exactly 3 or 4 numbers.<br>
The game usually expects colors to be in pre-multiplied form (color channels are pre-multiplied by alpha).
 
{|class="wikitable"
{|class="wikitable"
! name !! meaning !! type
! name !! meaning !! type
|-
|-
| r || red value || [[Types/float|float]]
| r || [optional, default 0] red value || [[Types/float|float]]
|-
|-
| g || green value || [[Types/float|float]]
| g || [optional, default 0] green value || [[Types/float|float]]
|-
|-
| b || blue value || [[Types/float|float]]
| b || [optional, default 0] blue value || [[Types/float|float]]
|-
|-
| a || [optional] alpha value - transparency || [[Types/float|float]]
| a || [optional, default 1] alpha value - transparency || [[Types/float|float]]
|}
|}


ex
== Examples ==
<pre>color={r=1, g=0, b=0, a=0.5}</pre>
    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

Latest revision as of 10:42, 21 September 2023

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/types/Color.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.


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