Skip to content
SinisterRectus edited this page Nov 16, 2019 · 12 revisions

Wrapper for 24-bit colors packed as a decimal value. See the static constructors for more information.

Constructor

Color(value)

Parameter Type
value number

Properties

Name Type Description
b number The value that represents the color's blue-level.
g number The value that represents the color's green-level.
r number The value that represents the color's red-level.
value number The raw decimal value that represents the color value.

Static Methods

fromHSL(h, s, l)

Parameter Type
h number
s number
l number

Constructs a new Color object from HSL values. Hue is allowed to overflow while saturation and lightness are clamped to [0, 1].

This method only operates on data in memory.

Returns: Color


fromHSV(h, s, v)

Parameter Type
h number
s number
v number

Constructs a new Color object from HSV values. Hue is allowed to overflow while saturation and value are clamped to [0, 1].

This method only operates on data in memory.

Returns: Color


fromHex(hex)

Parameter Type
hex string

Constructs a new Color object from a hexadecimal string. The string may or may not be prefixed by #; all other characters are interpreted as a hex string.

This method only operates on data in memory.

Returns: Color


fromRGB(r, g, b)

Parameter Type
r number
g number
b number

Constructs a new Color object from RGB values. Values are allowed to overflow though one component will not overflow to the next component.

This method only operates on data in memory.

Returns: Color


Methods

copy()

Returns a new copy of the original color object.

This method only operates on data in memory.

Returns: Color


setBlue()

Sets the color's blue-level.

This method only operates on data in memory.

Returns: nil


setGreen()

Sets the color's green-level.

This method only operates on data in memory.

Returns: nil


setRed()

Sets the color's red-level.

This method only operates on data in memory.

Returns: nil


toHSL()

Returns the hue, saturation, and lightness that represents the color value.

This method only operates on data in memory.

Returns: number, number, number


toHSV()

Returns the hue, saturation, and value that represents the color value.

This method only operates on data in memory.

Returns: number, number, number


toHex()

Returns a 6-digit hexadecimal string that represents the color value.

This method only operates on data in memory.

Returns: string


toRGB()

Returns the red, green, and blue values that are packed into the color value.

This method only operates on data in memory.

Returns: number, number, number


Clone this wiki locally