Constructor
new Color24(ropt, gopt, bopt)
Creates a new 24-bit RGB color.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
r |
number |
<optional> |
0 | The red component. |
g |
number |
<optional> |
0 | The green component. |
b |
number |
<optional> |
0 | The blue component. |
- Source:
Members
(readonly) blue :rune.util.ColorComponent
The blue component (in 8 bits), ie, a value between 0 and 255.
Type:
- rune.util.ColorComponent
- Source:
(readonly) green :rune.util.ColorComponent
The green component (in 8 bits), ie, a value between 0 and 255.
Type:
- rune.util.ColorComponent
- Source:
(readonly) red :rune.util.ColorComponent
The red component (in 8 bits), ie, a value between 0 and 255.
Type:
- rune.util.ColorComponent
- Source:
Methods
dispose() → {undefined}
Disposes this color.
- Source:
Returns:
- Type
- undefined
lerp(target, amount) → {rune.color.Color24}
Blends this color toward a target in place. Repeated calls blend from the
current value; use static lerp(start, target, amount, output) with a fixed
start color for a time-based transition. This method does not allocate colors.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
rune.color.Color24 | Target color. |
amount |
number | Blend amount, clamped to the interval zero to one. |
- Source:
Throws:
-
-
If target is not a Color24.
- Type
- TypeError
-
-
-
If amount is not a finite number.
- Type
- RangeError
-
Returns:
This color.
- Type
- rune.color.Color24
random() → {undefined}
Generates a random color for this object.
- Source:
Returns:
- Type
- undefined
setRGB(r, g, b) → {undefined}
Sets the color instance to the specified RGB value.
Parameters:
| Name | Type | Description |
|---|---|---|
r |
number | The red component (in 8 bits), ie, a value between 0 and 255. |
g |
number | The green component (in 8 bits), ie, a value between 0 and 255. |
b |
number | The blue component (in 8 bits), ie, a value between 0 and 255. |
- Source:
Returns:
- Type
- undefined
toString() → {string}
Returns a 24-bit hex representation of this color, as a string.
- Source:
Returns:
- Type
- string
(static) fromHex(s) → {rune.color.Color24}
Creates and returns a new Color24 object, based on a hexadecimal value,
specified in string format.
Parameters:
| Name | Type | Description |
|---|---|---|
s |
string | String-based color code (as hexadecimal). |
- Source:
Returns:
- Type
- rune.color.Color24
(static) lerp(start, target, amount, outputopt) → {rune.color.Color24}
Linearly interpolates RGB components without changing either input, unless
output aliases an input. Components are rounded to whole bytes. This blends
stored RGB values directly, without gamma correction. Color32 inputs are
accepted, but alpha is neither read nor changed by this RGB-only method.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
start |
rune.color.Color24 | Starting color. | |
target |
rune.color.Color24 | Target color. | |
amount |
number | Blend amount, clamped to the interval zero to one. | |
output |
rune.color.Color24 |
<optional> |
Result color; allocated only if omitted. |
- Source:
Throws:
-
-
If an input or supplied output is not a Color24.
- Type
- TypeError
-
-
-
If amount is not a finite number.
- Type
- RangeError
-
Returns:
The output color.
- Type
- rune.color.Color24