Color
Summary
An RGB color
Class Properties
Name | Return Type | Description |
---|---|---|
black | Color Read-only | The color black |
blue | Color Read-only | The color blue |
cyan | Color Read-only | The color cyan |
gray | Color Read-only | The color gray |
green | Color Read-only | The color green |
grey | Color Read-only | The color grey |
magenta | Color Read-only | The color magenta |
red | Color Read-only | The color red |
white | Color Read-only | The color white |
yellow | Color Read-only | The color yellow |
Instance Properties
Name | Return Type | Description |
---|---|---|
this[index] | number Read/Write | The color component at the specified index |
r | number Read-only | The red component |
g | number Read-only | The green component |
b | number Read-only | The blue component |
a | number Read-only | The alpha component |
grayscale | number Read-only | The grayscale value |
gamma | Color Read-only | The gamma color space representation |
linear | Color Read-only | The linear color space representation |
maxColorComponent | number Read-only | The maximum color component value |
html | string Read-only | The HTML hex string of the color (for example "A4D0FF") |
greyscale | number Read-only | The grayscale value |
hsv | Vector3 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:
Name | Type | Default | Description |
---|---|---|---|
r | number | 0 | The red component of the color. Default is 0 |
g | number | 0 | The green component of the color. Default is 0 |
b | number | 0 | The blue component of the color. Default is 0 |
Example
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:
Name | Type | Default | Description |
---|---|---|---|
html | string | The HTML string representing the color |
Example
Color:Lerp(a, b, t)
Performs a linear interpolation between two colors
Returns: Color (The interpolated color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
a | The start color | ||
b | The end color | ||
t | number | The interpolation value. Should be between 0 and 1 |
Example
Color:LerpUnclamped(a, b, t)
Performs a linear interpolation between two colors without clamping the interpolation parameter
Returns: Color (color)
Parameters:
Example
Color:HsvToRgb(h, s, v)
Converts an HSV color to an RGB color
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
h | number | The hue value. Should be between 0 and 1 | |
s | number | The saturation value. Should be between 0 and 1 | |
v | number | The value value. Should be between 0 and 1 |
Example
Color:HsvToRgb(hsv)
Converts an HSV Vector3 to an RGB color
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
hsv | A Vector3 with xyz representing hsv. All values between 0 and 1 |
Example
Instance Methods
color:Add(other)
Adds the specified color to this color
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
other | The color to add |
Example
color:Add(r, g, b)
Adds the specified RGB values to this color
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
r | number | The red component value to add | |
g | number | The green component value to add | |
b | number | The blue component value to add |
Example
color:Subtract(other)
Subtracts the specified color from this color
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
other | The color to subtract |
Example
color:Subtract(r, g, b)
Subtracts the specified RGB values from this color
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
r | number | The red component value to subtract | |
g | number | The green component value to subtract | |
b | number | The blue component value to subtract |
Example
color:Multiply(value)
Multiplies this color by the specified value
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
value | number | The value to multiply |
Example
color:Multiply(r, g, b)
Multiplies this color by the specified RGB values
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
r | number | The red component value to multiply | |
g | number | The green component value to multiply | |
b | number | The blue component value to multiply |
Example
color:Divide(value)
Divides this color by the specified value
Returns: Color (color)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
value | number | The value to divide |
Example
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:
Name | Type | Default | Description |
---|---|---|---|
other | The color to compare |
Example
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:
Name | Type | Default | Description |
---|---|---|---|
r | number | The red component value to compare | |
g | number | The green component value to compare | |
b | number | The blue component value to compare |
Example
Last updated