Skip to content

Latest commit

 

History

History
414 lines (188 loc) · 11.9 KB

File metadata and controls

414 lines (188 loc) · 11.9 KB

Color

Summary

An RGB color

Class Properties

NameReturn TypeDescription
blackColor
Read-only
The color black
blueColor
Read-only
The color blue
cyanColor
Read-only
The color cyan
grayColor
Read-only
The color gray
greenColor
Read-only
The color green
greyColor
Read-only
The color grey
magentaColor
Read-only
The color magenta
redColor
Read-only
The color red
whiteColor
Read-only
The color white
yellowColor
Read-only
The color yellow

Instance Properties

NameReturn TypeDescription
this[index]number
Read/Write
The color component at the specified index
rnumber
Read-only
The red component
gnumber
Read-only
The green component
bnumber
Read-only
The blue component
anumber
Read-only
The alpha component
grayscalenumber
Read-only
The grayscale value
gammaColor
Read-only
The gamma color space representation
linearColor
Read-only
The linear color space representation
maxColorComponentnumber
Read-only
The maximum color component value
htmlstring
Read-only
The HTML hex string of the color (for example "A4D0FF")
greyscalenumber
Read-only
The grayscale value
hsvVector3
Read-only
The hue, saturation and brightess

Class Methods

Color:New(r, g, b)

Creates a new instance of a color with the specified RGB values

Returns: Color (instance of the Color)

Parameters:

NameTypeDefaultDescription
rnumber0The red component of the color. Default is 0
gnumber0The green component of the color. Default is 0
bnumber0The blue component of the color. Default is 0

Example

myColor = Color:New(0.5, 0, 1)

Color:New(html)

Creates a new instance of the Color with the color parsed from the specified HTML string

Returns: Color (Returns the color. Invalid html inputs return bright magenta (r=1, g=0, b=1))

Parameters:

NameTypeDefaultDescription
htmlstringThe HTML string representing the color

Example

myColor = Color:New("D3B322")

Color:Lerp(a, b, t)

Performs a linear interpolation between two colors

Returns: Color (The interpolated color)

Parameters:

NameTypeDefaultDescription
aColorThe start color
bColorThe end color
tnumberThe interpolation value. Should be between 0 and 1

Example

newColor = Color:Lerp(color1, color2, 0.5)

Color:LerpUnclamped(a, b, t)

Performs a linear interpolation between two colors without clamping the interpolation parameter

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
aColorThe start color
bColorThe end color
tnumberThe interpolation value

Example

newColor = Color:Lerp(color1, color2, 1.5)

Color:HsvToRgb(h, s, v)

Converts an HSV color to an RGB color

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
hnumberThe hue value. Should be between 0 and 1
snumberThe saturation value. Should be between 0 and 1
vnumberThe value value. Should be between 0 and 1

Example

newColor = Color:HsvToRgb(0.5, 0.9, 0.5)

Color:HsvToRgb(hsv)

Converts an HSV Vector3 to an RGB color

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
hsvVector3A Vector3 with xyz representing hsv. All values between 0 and 1

Example

newColor = Color:HsvToRgb(myHsv)

Instance Methods

color:Add(other)

Adds the specified color to this color

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
otherColorThe color to add

Example

newColor = color1:Add(color2)

color:Add(r, g, b)

Adds the specified RGB values to this color

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
rnumberThe red component value to add
gnumberThe green component value to add
bnumberThe blue component value to add

Example

newColor = color1:Add(0.5, 0, 0.1)

color:Subtract(other)

Subtracts the specified color from this color

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
otherColorThe color to subtract

Example

newColor = color1:Subtract(color2)

color:Subtract(r, g, b)

Subtracts the specified RGB values from this color

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
rnumberThe red component value to subtract
gnumberThe green component value to subtract
bnumberThe blue component value to subtract

Example

newColor = color1:Subtract(0.5, 0.25, 0)

color:Multiply(value)

Multiplies this color by the specified value

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
valuenumberThe value to multiply

Example

newColor = color1:Multiply(0.5)

color:Multiply(r, g, b)

Multiplies this color by the specified RGB values

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
rnumberThe red component value to multiply
gnumberThe green component value to multiply
bnumberThe blue component value to multiply

Example

newColor = color1:Multiply(0.85, 0, 0)

color:Divide(value)

Divides this color by the specified value

Returns: Color (color)

Parameters:

NameTypeDefaultDescription
valuenumberThe value to divide

Example

newColor = color1:Divide(0.5)

color:NotEquals(other)

Determines whether this color is not equal to the specified color

Returns: boolean (true if this color is not equal to the specified color; otherwise, false)

Parameters:

NameTypeDefaultDescription
otherColorThe color to compare

Example

if color1:NotEquals(color2) then print("colors are different") end

color:NotEquals(r, g, b)

Determines whether this color is not equal to the specified RGB values

Returns: boolean (true if this color is not equal to the specified RGB values; otherwise, false)

Parameters:

NameTypeDefaultDescription
rnumberThe red component value to compare
gnumberThe green component value to compare
bnumberThe blue component value to compare

Example

if color1:NotEquals(0, 1, 0) then print("color is not green") end