🎨Color

Color metatable

Fields

Name
Type
Description

r

number

red

g

number

green

b

number

blue

a

number

alpha

Color(r [?]: number, g [?]: number, b [?]: number, a [?]: number): Color

Name
Type
Description

r [?]

number

(default: 255)

g [?]

number

(default: 255)

b [?]

number

(default: 255)

a [?]

number

(default: 255)

Create a new Color.


Color(hex: string): Color

Name
Type
Description

hex

string

Hex string. Do not use "#" symbol.

Create a new Color from hex string.


:AsFraction(r: number, g: number, b: number, a: number): Color

Name
Type
Description

r

number

New R color range as a percentage in the range [0.0, 1.0]

g

number

New G color range as a percentage in the range [0.0, 1.0]

b

number

New B color range as a percentage in the range [0.0, 1.0]

a

number

New A color range as a percentage in the range [0.0, 1.0]

Overwrites the color's ranges using the fraction values. Returns itself.


:AsInt(value: number): Color

Name
Type
Description

value

number

int color value

Overwrites the color's ranges converting the int value to RGBA values. Returns itself.


:AsHsv(h: number, s: number, v: number, a: number): Color

Name
Type
Description

h

number

Hue color range [0.0, 1.0]

s

number

Saturation color range [0.0, 1.0]

v

number

Value color range [0.0, 1.0]

a

number

Alpha color range [0.0, 1.0]

Overwrites the color's ranges converting the HSV to RGBA values. Returns itself.


:AsHsl(h: number, s: number, l: number, a: number): Color

Name
Type
Description

h

number

Hue color range [0.0, 1.0]

s

number

Saturation color range [0.0, 1.0]

l

number

Lightness color range [0.0, 1.0]

a

number

Alpha color range [0.0, 1.0]

Overwrites the color's ranges converting the HSL to RGBA values. Returns itself.


:ToFraction(): number, number, number, number

Returns the r, g, b, and a ranges of the color as a percentage in the range of [0.0, 1.0].


:ToInt(): number

Returns the int value representing the color.


:ToHsv(): number, number, number

Returns the HSV representation of the color.


:ToHsl(): number, number, number

Returns the ToHsl representation of the color.


:ToHex(): string

Returns the hex string representing the color.


:Lerp(other: Color, weight: number): Color

Name
Type
Description

other

The color to interpolate to

weight

number

A value between 0 and 1 that indicates the weight of other

Returns the linearly interpolated color between two colors by the specified weight.


:Grayscale(weight: number): Color

Name
Type
Description

weight

number

A value between 0 and 1 that indicates the weight of grayscale

Returns the grayscaled color.


:AlphaModulate(alpha: number): Color

Name
Type
Description

alpha

number

Alpha color range [0.0, 1.0]

Returns the alpha modulated color.


:Clone(): Color

Creates and returns a copy of the color object.


:Unpack(): number, number, number, number

Returns the r, g, b, and a values of the color. Note that these fields can be accessed by indexing r, g, b, and a.


:__tostring(): string

Returns hex string representing the color.


Color(r [?]: number, g [?]: number, b [?]: number, a [?]: number): Color

Name
Type
Description

r [?]

number

(default: 255)

g [?]

number

(default: 255)

b [?]

number

(default: 255)

a [?]

number

(default: 255)

Create a new Color.


Color(hex: string): Color

Name
Type
Description

hex

string

Hex string. Do not use "#" symbol.

Create a new Color from hex string.


:AsFraction(r: number, g: number, b: number, a: number): Color

Name
Type
Description

r

number

New R color range as a percentage in the range [0.0, 1.0]

g

number

New G color range as a percentage in the range [0.0, 1.0]

b

number

New B color range as a percentage in the range [0.0, 1.0]

a

number

New A color range as a percentage in the range [0.0, 1.0]

Overwrites the color's ranges using the fraction values. Returns itself.


:AsInt(value: number): Color

Name
Type
Description

value

number

int color value

Overwrites the color's ranges converting the int value to RGBA values. Returns itself.


:AsHsv(h: number, s: number, v: number, a: number): Color

Name
Type
Description

h

number

Hue color range [0.0, 1.0]

s

number

Saturation color range [0.0, 1.0]

v

number

Value color range [0.0, 1.0]

a

number

Alpha color range [0.0, 1.0]

Overwrites the color's ranges converting the HSV to RGBA values. Returns itself.


:AsHsl(h: number, s: number, l: number, a: number): Color

Name
Type
Description

h

number

Hue color range [0.0, 1.0]

s

number

Saturation color range [0.0, 1.0]

l

number

Lightness color range [0.0, 1.0]

a

number

Alpha color range [0.0, 1.0]

Overwrites the color's ranges converting the HSL to RGBA values. Returns itself.


:ToFraction(): number, number, number, number

Returns the r, g, b, and a ranges of the color as a percentage in the range of [0.0, 1.0].


:ToInt(): number

Returns the int value representing the color.


:ToHsv(): number, number, number

Returns the HSV representation of the color.


:ToHsl(): number, number, number

Returns the ToHsl representation of the color.


:ToHex(): string

Returns the hex string representing the color.


:Lerp(other: Color, weight: number): Color

Name
Type
Description

other

The color to interpolate to

weight

number

A value between 0 and 1 that indicates the weight of other

Returns the linearly interpolated color between two colors by the specified weight.


:Grayscale(weight: number): Color

Name
Type
Description

weight

number

A value between 0 and 1 that indicates the weight of grayscale

Returns the grayscaled color.


:AlphaModulate(alpha: number): Color

Name
Type
Description

alpha

number

Alpha color range [0.0, 1.0]

Returns the alpha modulated color.


:Clone(): Color

Creates and returns a copy of the color object.


:Unpack(): number, number, number, number

Returns the r, g, b, and a values of the color. Note that these fields can be accessed by indexing r, g, b, and a.


:__tostring(): string

Returns hex string representing the color.

Last updated