Color

From Garry's Mod
Jump to: navigation, search
 Color( )

Contents

Description

Creates a Color structure.

Arguments

number r

An integer from 0-255 describing the red value of the color.

Arguments

number g

An integer from 0-255 describing the green value of the color.

Arguments

number b

An integer from 0-255 describing the blue value of the color.

Arguments

number a=255

An integer from 0-255 describing the alpha (transparency) of the color.

Returns

table

The created Color structure.

Examples

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

Examples

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

Examples

Example

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

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

Output:

255 0 0

Examples

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
Personal tools
Navigation