Class: ColorUtils
Utility methods for working with color values.
Extends
unknown
Constructors
Constructor
new ColorUtils(): ColorUtils;
Returns
ColorUtils
Inherited from
ProxyLiveObject.constructor
Methods
fromRGB()
Call Signature
fromRGB(
red,
green,
blue,
alpha?): Color;
Create a new color object with the given RGBA values.
Parameters
Parameter
Type
Description
rednumberThe red channel, from 0 - 1.
greennumberThe green channel, from 0 - 1.
bluenumberThe blue channel, from 0 - 1.
alpha?numberOptional alpha channel, from 0 - 1. Defaults to 1 (opaque).
Returns
A new color object.
Call Signature
fromRGB(color): Color;
Create a new color object given a partial color object where the alpha field may be missing.
Parameters
Parameter
Type
Description
color{
red: number; green: number; blue: number; alpha?: number; }Partial color object. Alpha defaults to 1 (opaque).
color.rednumber-
color.greennumber-
color.bluenumber-
color.alpha?number-
Returns
A new color object with all fields present.
fromHex()
fromHex(hex): Color;
Create a new color from its equivalent RGBA hex representation. Can specify in 6 digits (RRGGBB) or 8 digits (RRGGBBAA), uppercase or lowercase, with or without leading "#". Alpha defaults to FF (100% opaque) if ommitted.
Parameters
Parameter
Type
Description
hexstringThe color represented as a hexadecimal string.
Returns
A new color value matching the given hex string.
Throws
if the hex string cannot be parsed.
toHex()
toHex(color): string;
Get the color in 8-digit hex "#RRGGBBAA" format.
Parameters
Parameter
Type
colorReturns
string