Creates a new instance of Color from an r, g, b, a
The red component of color (0-255)
The green component of color (0-255)
The blue component of color (0-255)
The alpha component of color (0-1.0)
Alpha channel (between 0 and 1)
Blue channel
Green channel
Hue
Lightness
Red channel
Saturation
Azure (#007FFF)
Black (#000000)
Blue (#0000FF)
Chartreuse (#7FFF00)
Cyan (#00FFFF)
Dark gray (#A9A9A9)
Gray (#808080)
Green (#00FF00)
Light gray (#D3D3D3)
Magenta (#FF00FF)
Orange (#FFA500)
Red (#FF0000)
Rose (#FF007F)
Transparent (#FFFFFF00)
Vermilion (#FF5B31)
Vermilion (#FF5B31)
Violet (#7F00FF)
Viridian (#59978F)
White (#FFFFFF)
Yellow (#FFFF00)
Returns a clone of the current color.
Darkens the current color by a specified amount
The amount to darken by [0-1]
Desaturates the current color by a specified amount
The amount to desaturate by [0-1]
Returns a CSS string representation of a color.
Inverts the current color
Lightens the current color by a specified amount
The amount to lighten by [0-1]
Saturates the current color by a specified amount
The amount to saturate by [0-1]
Return HSLA representation of a color.
Return Hex representation of a color.
Return RGBA representation of a color.
Returns a CSS string representation of a color.
Color representation, accepts: rgb, hsl, or hex
Creates a new instance of Color from hsla values
Hue is represented [0-1]
Saturation is represented [0-1]
Luminance is represented [0-1]
Alpha is represented [0-1]
Creates a new instance of Color from a hex string
CSS color string of the form #ffffff, the alpha component is optional
Creates a new instance of Color from an r, g, b, a
The red component of color (0-255)
The green component of color (0-255)
The blue component of color (0-255)
The alpha component of color (0-1.0)
Provides standard colors (e.g. Color.Black) but you can also create custom colors using RGB, HSL, or Hex. Also provides useful color operations like Color.lighten, Color.darken, and more.
Creating colors
// RGBA new ex.Color(r, g, b, a); ex.Color.fromRGB(r, g, b, a); // HSLA ex.Color.fromHSL(h, s, l, a); // Hex, alpha optional ex.Color.fromHex('#000000'); ex.Color.fromHex('#000000FF'); // String representation of a color with rgb as default // Options include rgb,hsl,hex ex.Color.toString('rgb');
Working with colors
Since Javascript does not support structs, if you change a color "constant" like Color.Black it will change it across the entire game. You can safely use the color operations like Color.lighten and Color.darken because they
clone
the color to return a new color. However, be aware that this can use up memory if used excessively.Just be aware that if you directly alter properties (i.e. Color.r, etc.) , this will change it for all the code that uses that instance of Color.