Color related functions - DPS2004/Doctor-s-Notepad GitHub Wiki

The functions on this page are available by loading the color.lua extension. It is loaded by default.

level:rgb(r, g, b)

Returns a string in hexadecimal format, with the first two characters being the red channel, next two being green and last two being blue.
r, g and b should be between 0 and 255.

Example:

print( level:rgb(255, 0, 0) ) -- prints 'FF0000'

level:rgba(r, g, b, a)

Returns a string in hexadecimal format, with the first two characters being the red channel, next two being green, next two being blue and last two being alpha.
r, g, b, a should be between 0 and 255.

Example:

print( level:rgb(255, 0, 0, 127) ) -- prints 'FF00007F'

level:hsvraw(h, s, v)

Returns three numbers, the red, green and blue channels obtained at h hue, s saturation and v value.
h, s and v should be between 0 and 255.

Example:

local r, g, b = level:hsvraw(32, 255, 255)
print(r, g, b) -- prints '255		192		0'

level:hsvaraw(h, s, v, a)

Returns four numbers, the red, green, blue and alpha channels obtained at h hue, s saturation and v value.
h, s, v and a should be between 0 and 255.

Example:

local r, g, b, a = level:hsvaraw(32, 255, 255, 127)
print(r, g, b, a) -- prints '255		192		0		127'

level:hsv(h, s, v)

Returns a string in hexadecimal format, with the first two characters being the red channel, next two being green and last two being blue.
h, s and v should be between 0 and 255.

Example:

print( level:hsv(255, 127, 255) ) -- prints 'FF8080'

level:hsva(h, s, v, a)

Returns a string in hexadecimal format, with the first two characters being the red channel, next two being green, next two being blue and last two being alpha.
h, s, v and a should be between 0 and 255.

Example:

print( level:hsv(255, 127, 255, 255) ) -- prints 'FF8080FF'