Garry's Mod Wiki

Color

table Color( number r, number g, number b, number a = 255 )

Description

Creates a Color.

Arguments

1 number r
An integer from 0-255 describing the red value of the color.
2 number g
An integer from 0-255 describing the green value of the color.
3 number b
An integer from 0-255 describing the blue value of the color.
4 number a = 255
An integer from 0-255 describing the alpha (transparency) of the color.

Returns

1 table
The created Color.

Example

Creates a color and prints the components to the console.

PrintTable(Color(1, 2, 3, 4))
Output:
a = 4 b = 3 g = 2 r = 1

Example

Color variables can have individual channels set using the arguments

local col = Color( 0, 255, 0, 255) col.r = 255 PrintTable(col)
Output:
a = 255 b = 0 g = 255 r = 255

Example

Transforms a color object to a string, then prints it.

local str = tostring( Color( 255, 0, 0 ) ) print( str )
Output: 255 0 0

Example

Prints "equal" if both colors are equal, otherwise "unequal" will be printed.

if Color( 255, 0, 0 ) == Color( 255, 0, 0 ) then print( "equal" ) else print( "unequal" ) end
Output: equal

Page Links


Special Pages


Wikis

?

Render Time: 42ms

Session 0
DB GetPage 7
Generate Html 3
SaveChanges 17
Render Body 0
Render Sidebar 13