Class: Color32

rune.color.Color32(ropt, gopt, bopt, aopt)

Represents a 32-bit RGB color. A color consists of four 8-bit components; red, green, blue and alpha.

Constructor

new Color32(ropt, gopt, bopt, aopt)

Creates a new 32-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.
a number <optional>
255 The alpha component; zero is fully transparent.
Source:

Extends

Members

(readonly) alpha :rune.util.ColorComponent

The alpha component (in 8 bits), ie, a value between 0 and 255.
Type:
  • rune.util.ColorComponent
Source:

(readonly) blue :rune.util.ColorComponent

The blue component (in 8 bits), ie, a value between 0 and 255.
Type:
  • rune.util.ColorComponent
Inherited From:
Source:

(readonly) green :rune.util.ColorComponent

The green component (in 8 bits), ie, a value between 0 and 255.
Type:
  • rune.util.ColorComponent
Inherited From:
Source:

(readonly) red :rune.util.ColorComponent

The red component (in 8 bits), ie, a value between 0 and 255.
Type:
  • rune.util.ColorComponent
Inherited From:
Source:

Methods

dispose() → {undefined}

Disposes this color.
Overrides:
Source:
Returns:
Type
undefined

lerp(target, amount) → {rune.color.Color32}

Blends this color toward a Color32 target, including alpha, without allocating colors. Use static lerp() with a fixed start color for a time-based transition.
Parameters:
Name Type Description
target rune.color.Color24 Target color; must be a Color32.
amount number Blend amount, clamped to the interval zero to one.
Overrides:
Source:
Throws:
  • If target is not a Color32.
    Type
    TypeError
  • If amount is not a finite number.
    Type
    RangeError
Returns:
This color.
Type
rune.color.Color32

random() → {undefined}

Generates a random color for this object.
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
undefined

setRGBA(r, g, b, a) → {undefined}

Sets the color instance to the specified RGBA 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.
a number The alpha component (in 8 bits), ie, a value between 0 and 255.
Source:
Returns:
Type
undefined

toString() → {string}

Returns a 32-bit RGBA representation of this color, as a string.
Overrides:
Source:
Returns:
Type
string

(static) fromHex(s) → {rune.color.Color32}

Creates and returns a new Color32 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.Color32

(static) lerp(start, target, amount, outputopt) → {rune.color.Color32}

Linearly interpolates RGBA components into an optional reusable output color. Reuses Color24 interpolation for RGB; alpha is blended independently, without premultiplication. Components are rounded to whole bytes. Output may alias either input. Inputs remain unchanged when output is a separate color.
Parameters:
Name Type Attributes Description
start rune.color.Color32 Starting color.
target rune.color.Color32 Target color.
amount number Blend amount, clamped to the interval zero to one.
output rune.color.Color32 <optional>
Result color; allocated only if omitted.
Source:
Throws:
  • If an input or supplied output is not a Color32.
    Type
    TypeError
  • If amount is not a finite number.
    Type
    RangeError
Returns:
The output color.
Type
rune.color.Color32