Color - truemedian/Discordia GitHub Wiki

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

Static Methods

fromHex
fromRGB
fromHSV
fromHSL

Methods

toHex
toRGB
toHSV
toHSL
setRed
setGreen
setBlue
toHSL

Properties

value
r
g
b

Static Methods

.fromHex( hex )

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.

Name Type
hex string

Returns: Color

.fromRGB( r, g, b )

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

Name Type
r number
g number
b number

Returns: Color

.fromHSV( h, s, v )

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

Name Type
h number
s number
v number

Returns: Color

.fromHSL( h, s, l )

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

Name Type
h number
s number
l number

Returns: Color

Methods

:toHex( )

Returns the hexadecimal string that represents the color value.

Returns: string

:toRGB( )

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

Returns: number, number, number

:toHSV( )

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

Returns: number, number, number

:toHSL( )

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

Returns: number, number, number

:setRed( )

Sets the color's red-level.

Returns: nil

:setGreen( )

Sets the color's green-level.

Returns: nil

:setBlue( )

Sets the color's blue-level.

Returns: nil

:toHSL( )

Returns a new copy of the original color object.

Returns: Color

Properties

.value

The raw decimal value that represents the color value.

Type: number

.r

The value that represents the color's red-level.

Type: number

.g

The value that represents the color's green-level.

Type: number

.b

The value that represents the color's blue-level.

Type: number

⚠️ **GitHub.com Fallback** ⚠️