gs.Color Class
A class to describe RGBA colors. It also offers some helper methods.
Constructor
gs.Color
-
red/color
-
[green=null]
-
[blue=null]
-
[alpha=null]
Parameters:
-
red/color
Number- The red value of the color OR another color to create a copy from.
-
[green=null]
Number optional- The green value of the color.
-
[blue=null]
Number optional- The blue value of the color.
-
[alpha=null]
Number optional- The alpha value of the color.
Item Index
Methods
equals
-
color
Checks if the color is equal to the specified color.
Parameters:
-
color
gs.Color- The color to compare to.
Returns:
If true both colors are equal. Otherwise false
fromArray
-
a
Creates a new color from the specified color-value array. The should have 4 elements with the red, green, blue and alpha color-values in that order.
Parameters:
-
a
Number- An array of color-values.
Returns:
A new created color with the specified color-values.
fromObject
-
o
Creates a color from an raw object. The object should contain 4 properties named red, green, blue and alpha.
Parameters:
-
o
Object- The object with the red, green, blue and alpha properties of the color.
Returns:
The new created color.
rgbToHsl
-
r
-
g
-
b
Converts the specified RGB value to HSL space.
Parameters:
-
r
Number- The red value of the color to convert.
-
g
Number- The green value of the color to convert.
-
b
Number- The blue value of the color to convert.
Returns:
The HSL values as object -> { h, s, l }.
rgbToHsl
-
h
-
s
-
l
Converts the specified HSL value to RGB space.
Parameters:
-
h
Number- The HUE value of the color to convert.
-
s
Number- The saturation value of the color to convert.
-
l
Number- The lightness value of the color to convert.
Returns:
The RGB values as object -> { r, g, b }.
set
-
[red/color=null]
-
[green=null]
-
[blue=null]
-
[alpha=null]
Sets the color values.
Parameters:
-
[red/color=null]
Number optional- The red value of the color OR another color to copy the color values from.
-
[green=null]
Number optional- The green value of the color.
-
[blue=null]
Number optional- The blue value of the color.
-
[alpha=null]
Number optional- The alpha value of the color.
toString
()
String
Returns the color as CSS string like rgba(r, g, b, a).
Returns:
The CSS string.
Properties
alpha
Number
The alpha value of the color.
blue
Number
The blue value of the color.
green
Number
The green value of the color.
red
Number
The red value of the color.