color
color
The color class represents RGBA color values with channels normalized from 0.0 to 1.0. Supports hex HTML parsing, byte channel creation (color8), linear interpolation, darkening, and lightening.
Overview
Properties (4)
| Property | Type | Summary |
|---|---|---|
a
|
number
|
Alpha (transparency) channel. |
b
|
number
|
Blue color channel. |
g
|
number
|
Green color channel. |
r
|
number
|
Red color channel. |
Methods (7)
| Method Signature | Returns | Summary |
|---|---|---|
color.color8(r, g, b, [a = 255])
|
color
|
Constructs a color from 0-255 integer byte values. |
color:darkened(amount)
|
color
|
Returns a darkened version of the color. |
color.fromHtml(html)
|
color
|
Creates a color from an HTML/hex string. |
color:inverted()
|
color
|
Returns the color with inverted RGB channels. |
color:lerp(to, weight)
|
color
|
Linearly interpolates between colors. |
color:lightened(amount)
|
color
|
Returns a lightened version of the color. |
color.new(r, g, b, [a = 1.0])
|
color
|
Constructs a color from normalized float values. |
Detailed Reference
color.anumberAlpha channel (0.0 to 1.0).
Gets or sets the alpha component.
color.bnumberBlue channel (0.0 to 1.0).
Gets or sets the blue component.
color.gnumberGreen channel (0.0 to 1.0).
Gets or sets the green component.
color.rnumberRed channel (0.0 to 1.0).
Gets or sets the red component.
color.color8(r, g, b, [a = 255])| Parameter | Type | Default | Description |
|---|---|---|---|
r | number | Red byte (0 - 255). | |
g | number | Green byte (0 - 255). | |
b | number | Blue byte (0 - 255). | |
a | number | `255` | Alpha byte (0 - 255). |
colorNewly created color.
Creates a color using standard 8-bit integer channel values.
color:darkened(amount)| Parameter | Type | Default | Description |
|---|---|---|---|
amount | number | Darkening percentage (0.0 - 1.0). |
colorDarkened color.
Interpolates the color toward black.
color.fromHtml(html)| Parameter | Type | Default | Description |
|---|---|---|---|
html | string | Hex string such as |
colorParsed color object.
Parses standard HTML hex color notation.
local red = color.fromHtml("#FF0000")color:inverted()colorInverted color.
Calculates $(1-r, 1-g, 1-b, a)$.
color:lerp(to, weight)| Parameter | Type | Default | Description |
|---|---|---|---|
to | color | Target color. | |
weight | number | Interpolation factor (0.0 - 1.0). |
colorInterpolated color.
Performs linear blend between this color and to.
color:lightened(amount)| Parameter | Type | Default | Description |
|---|---|---|---|
amount | number | Lightening percentage (0.0 - 1.0). |
colorLightened color.
Interpolates the color toward white.
color.new(r, g, b, [a = 1.0])| Parameter | Type | Default | Description |
|---|---|---|---|
r | number | Red channel (0.0 - 1.0). | |
g | number | Green channel (0.0 - 1.0). | |
b | number | Blue channel (0.0 - 1.0). | |
a | number | `1.0` | Alpha channel (0.0 - 1.0). |
colorNewly created color.
Creates a color with specified RGBA channels.
local c = color.new(1.0, 0.5, 0.0, 1.0)