colour

From Teverse

A colour is a data type which represents an RGB colour. Colours can be created through the colour(r,g,b) and colour:new(r,g,b), which take RGB values 0-1, or colour:fromRGB(r,g,b), which is similar to the other two constructors but takes values of 0-255 instead of 0-1.

Examples:

local white = colour(1,1,1) -- Pure white
local black = colour(0,0,0) -- Pure black
local gray = colour(0.5,0.5,0.5) -- Gray

In order to use a 0-255 scale:

local skyBlue = colour:fromRGB(72, 217, 250) -- Equivalent to #48d9fa, or sky blue.

Properties

r

Type: number
The R channel of the colour.

g

Type: number
The G channel of the colour.

b

Type: number
The B channel of the colour.

Operators

colour + colour

Combines the value of two colours and returns the result.

colour - colour

colour * colour

colour / colour

Methods

getHex

string colour:getHex()
Returns the hex of the colour (eg. FF0000).

getRGB

number, number, number colour:getRGB()
Returns the RGB of the colour (0-255).

lerp

colour colour:lerp(colour target, number t)
returns an interpolated copy of the colour.
t is clamped between 0 and 1. If t is 0, the returned colour will be unchanged. If t is 1, the returned colour will be target

.