Creates a new Color instance.
A Color object or the red component [0 .. 255]. Defaults to 0.
The green component [0 .. 255]. Defaults to 0.
The blue component [0 .. 255]. Defaults to 0.
The alpha value [0.0 .. 1.0]. Defaults to 1.
Gets the alpha component of the color.
The alpha component [0.0 .. 1.0].
Sets the alpha component of the color.
The alpha component [0.0 .. 1.0].
Gets the blue component of the color.
The blue component [0 .. 255].
Sets the blue component of the color.
The blue component [0 .. 255].
Gets the green component of the color.
The green component [0 .. 255].
Sets the green component of the color.
The green component [0 .. 255].
Gets the red component of the color.
The red component [0 .. 255].
Sets the red component of the color.
The red component [0 .. 255].
Darkens this color value by a given scale.
The scale to darken the color by [0 .. 1].
Reference to this object for method chaining.
Checks if this color is equal to another.
The color to compare with.
True if the colors are equal, otherwise false.
Lightens this color value by a given scale
The scale to lighten the color by [0 .. 1].
Reference to this object for method chaining.
Parse a CSS color name and set this color to the corresponding r,g,b values
The CSS color name
Reference to this object for method chaining
Parse a Hex color ("#RGB", "#RGBA" or "#RRGGBB", "#RRGGBBAA" format) and set this color to the corresponding r,g,b,a values
The Hex color string to parse
Optionalargb: boolean = falsetrue if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)
Reference to this object for method chaining
Parse an RGB or RGBA CSS color string
The RGB or RGBA color string to parse
Reference to this object for method chaining
Generate random r,g,b values for this color object
Optionalmin: number = 0minimum value for the random range
Optionalmax: number = 255maxmium value for the random range
Reference to this object for method chaining
Sets the color to the specified values.
The red component [0 .. 255].
The green component [0 .. 255].
The blue component [0 .. 255].
Optionalalpha: number = 1.0The alpha value [0.0 .. 1.0]. Defaults to 1.
Reference to this object for method chaining.
Sets the color to the specified normalized float values.
The red component [0.0 .. 1.0].
The green component [0.0 .. 1.0].
The blue component [0.0 .. 1.0].
Optionalalpha: number = 1.0The alpha value [0.0 .. 1.0]. Defaults to 1.
Reference to this object for method chaining.
Sets the color from HSL values, with hue in [0..1] (the
GLSL / WebGL shader convention — 0 = red, 1/3 = green,
2/3 = blue, 1 = back to red). If you're coming from CSS /
Photoshop / D3 and have a hue in degrees (0..360), divide by
360 first — or call Color#setHSLDeg which does it for you.
Hue wraps at integer boundaries, so h = 1 and h = 0 produce
the same red. Saturation 0 short-circuits to a grey at the
requested lightness, ignoring hue. Lightness 0 or 1 produce
pure black or pure white regardless of the other two.
The hue, normalized to [0..1] (NOT degrees).
The saturation [0..1].
The lightness [0..1].
Reference to this object for method chaining.
Color#setHSLDeg for the degrees-based variant.
Sets the color from HSL values with hue in degrees [0..360]
— the CSS / Photoshop / D3 convention. Thin convenience wrapper
over Color#setHSL: divides hDeg by 360 and delegates.
Saturation and lightness stay in [0..1] (the same units CSS
percentages would normalize to).
Use this when you're working from CSS color values, color-picker
output, or any standard color reference. Prefer Color#setHSL
when your hue is already normalized (e.g. from Math.random(),
a noise function, or a shader uniform).
The hue in degrees [0..360]. Values outside the
range are accepted (the underlying hue calc wraps).
The saturation [0..1].
The lightness [0..1].
Reference to this object for method chaining.
Sets the color to the specified HSV values.
The hue [0 .. 1].
The saturation [0 .. 1].
The value [0 .. 1].
Reference to this object for method chaining.
return a Float Array representation of this object
A Float Array representation of this color
return the color in "#RRGGBB" format
The color in "#RRGGBB" format
Get the color in "#RRGGBBAA" format
The alpha value [0.0 .. 1.0] to use in the output string.
The color in "#RRGGBBAA" format
Get the color in "rgb(R,G,B)" format
The color in "rgb(R,G,B)" format
Get the color in "rgba(R,G,B,A)" format
Optionalalpha: number = ...alpha value [0.0 .. 1.0]
The color in "rgba(R,G,B,A)" format
Pack this color RGB components into a Uint32 ARGB representation
Optionalalpha: number = 1.0alpha value [0.0 .. 1.0]
A Uint32 ARGB representation of this color
A color manipulation object.