Revision Difference
Global.Color#514849
<function name="Color" parent="Global" type="libraryfunc">⤶
<description>Creates a <page>Color</page>.</description>⤶
<realm>Shared and Menu</realm>⤶
<file line="10-L18">lua/includes/util/color.lua</file>⤶
<args>⤶
<arg name="r" type="number">An integer from 0-255 describing the red value of the color.</arg>⤶
<arg name="g" type="number">An integer from 0-255 describing the green value of the color.</arg>⤶
<arg name="b" type="number">An integer from 0-255 describing the blue value of the color.</arg>⤶
<arg name="a" type="number" default="255">An integer from 0-255 describing the alpha (transparency) of the color.</arg>⤶
</args>⤶
<rets>⤶
<ret name="" type="table">The created <page>Color</page>.</ret>⤶
</rets>⤶
</function>⤶
⤶
<example>⤶
<description>Creates a color and prints the components to the console.</description>⤶
<code>PrintTable(Color(1, 2, 3, 4))</code>⤶
<output>⤶
⤶
```⤶
a = 4⤶
b = 3⤶
g = 2⤶
r = 1⤶
```⤶
⤶
</output>⤶
⤶
</example>⤶
⤶
⤶
<example>⤶
<description>Color variables can have individual channels set using the arguments</description>⤶
<code>⤶
local col = Color( 0, 255, 0, 255)⤶
⤶
col.r = 255⤶
⤶
PrintTable(col)⤶
</code>⤶
<output>⤶
⤶
```⤶
a = 255⤶
b = 0⤶
g = 255⤶
r = 255⤶
```⤶
⤶
</output>⤶
⤶
</example>⤶
⤶
⤶
<example>⤶
<description>Transforms a color object to a string, then prints it.</description>⤶
<code>⤶
local str = tostring( Color( 255, 0, 0 ) )⤶
print( str )⤶
</code>⤶
<output>255 0 0</output>⤶
⤶
</example>⤶
⤶
⤶
<example>⤶
<description>Prints "equal" if both colors are equal, otherwise "unequal" will be printed.</description>⤶
<code>⤶
if Color( 255, 0, 0 ) == Color( 255, 0, 0 ) then⤶
print( "equal" )⤶
else⤶
print( "unequal" )⤶
end⤶
</code>⤶
<output>equal</output>⤶
⤶
</example>