TruWorlds

Color4

Represents a color in RGBA space (with alpha for transparency).

Fields

RByte byte

The red component (0–255).

GByte byte

The green component (0–255).

BByte byte

The blue component (0–255).

AByte byte

The alpha component (0–255).

Properties

R float

The red component of the color, in the range [0.0, 1.0].

G float

The green component of the color, in the range [0.0, 1.0].

B float

The blue component of the color, in the range [0.0, 1.0].

A float

The alpha (opacity) component of the color, in the range [0.0, 1.0].

Functions

ToRgba32() Returns uint

Converts the color to a 32-bit unsigned integer in RGBA format.

Returns: The color as a 32-bit unsigned integer in RGBA format.

FromHsv(hue: float, saturation: float, value: float, transparency: float) Returns Color4

Creates a Color from HSV (Hue, Saturation, Value) components.

hue
The hue component, in the range [0.0, 1.0].
saturation
The saturation component, in the range [0.0, 1.0].
value
The value component, in the range [0.0, 1.0].
transparency
The transparency component, in the range [0.0, 1.0].

Returns: The resulting Color.

NewRandom() Returns Color4

Generates a random opaque color.

Returns: A random Color.

ToHex() Returns string

Converts the color to a hexadecimal (HTML) string representation.

Returns: The hexadecimal string representation of the color, in the format RRGGBBAA.

SetHex(hex: string) Returns Color4

Sets this color's components from a hexadecimal string (with or without a leading #).

hex
A 6- or 8-character hex string (RRGGBB or RRGGBBAA).

Returns: This color, with components updated to match .

FromHex(hex: string) Returns Color3

Creates a Color from a hexadecimal string (with or without a leading #).

hex
A 6-character RRGGBB hex string.

Returns: The resulting Color.

SetHsv(hue: float, saturation: float, value: float, transparency: float) Returns Color4

Sets this color from HSV (Hue, Saturation, Value) components.

hue
The hue component, in the range [0.0, 1.0].
saturation
The saturation component, in the range [0.0, 1.0].
value
The value component, in the range [0.0, 1.0].
transparency
The transparency component, in the range [0.0, 1.0].

Returns: This color, with components updated to match the HSV input.

Random() Returns Color4

Randomizes this color's RGB components.

Returns: This color, with randomized components.