Color Class
A color represented by red, green, blue, and alpha(RGBA) components. The alpha component is often used for transparency
Constructors
Color.__new()
Creates a default white color
Color.__new()
Color.__new(number,number,number,number)
Creates a new color using 255 range RGBA values.
Color.__new(r: number,g: number,b: number,a: number = 255)
Type | Name | Description |
---|---|---|
number | r | |
number | g | |
number | b | |
number | a |
Color.__new(string)
Creates a new color based on a hex string (i.e. ff6400)
Color.__new(hex: string)
Type | Name | Description |
---|---|---|
string | hex |
ReadOnly
Type | Name | Static | Default | Description |
---|---|---|---|---|
number | Luminance | Returns the light intensity of the color, as a value between 0.0 and 1.0 (inclusive). This is useful when determining light or dark color. Colors with a luminance smaller than 0.5 can be generally considered dark. |
Properties
Type | Getter | Setter | Static | Default | Description |
---|---|---|---|---|---|
number | get_A() | set_A(val) | Alpha (Used for transparency) | ||
number | get_B() | set_B(val) | Blue | ||
number | get_G() | set_G(val) | Green | ||
number | get_H() | set_H(val) | The HSV hue of this color | ||
number | get_R() | set_R(val) | Red | ||
number | get_S() | set_S(val) | The HSV saturation of this color | ||
number | get_V() | set_V(val) | The HSV value (brightness) of this color |
Functions
Requires an instance!
Inverted
Returns the inverted color: (1 - r, 1 - g, 1 - b, a).
Inverted() -> Color
Lightened(number)
Returns a new color resulting from making this color lighter by the specified ratio (on the range of 0 to 1).
Lightened(amount: number) -> Color
Type | Name | Description |
---|---|---|
number | amount |
Darkened(number)
Returns a new color resulting from making this color darker by the specified ratio (on the range of 0 to 1).
Darkened(amount: number) -> Color
Type | Name | Description |
---|---|---|
number | amount |
Lerp(Color,number)
Returns the result of the linear interpolation between this color and by amount .
Lerp(to: Color,weight: number) -> Color
Type | Name | Description |
---|---|---|
Color | to | The destination color for interpolation. |
number | weight | A value on the range of 0.0 to 1.0, representing the amount of interpolation. |
Greyscale
Converts the current color to its grayscale equivalent using the luminance formula based on human visual perception.
Greyscale() -> Color
IsCloseTo(Color,number)
Checks if this color is close to another color within a specified tolerance ratio of (0.0 to 1.0).
IsCloseTo(comparison: Color,tolerance: number = 0.01) -> boolean
Type | Name | Description |
---|---|---|
Color | comparison | |
number | tolerance |