API Docs for:
Show:

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

Properties

Methods

equals

(
  • color
)
Boolean

Checks if the color is equal to the specified color.

Parameters:

  • color gs.Color
    • The color to compare to.

Returns:

Boolean:

If true both colors are equal. Otherwise false

fromArray

(
  • a
)
gs.Color static

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:

gs.Color:

A new created color with the specified color-values.

fromObject

(
  • o
)
gs.Color static

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:

gs.Color:

The new created color.

rgbToHsl

(
  • r
  • g
  • b
)
Object static

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:

Object:

The HSL values as object -> { h, s, l }.

rgbToHsl

(
  • h
  • s
  • l
)
Object static

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:

Object:

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:

String:

The CSS string.

Properties

alpha

Number

The alpha value of the color.

BLACK

gs.Color final static

Black 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.

TRANSPARENT

gs.Color final static

Transparent color

WHITE

gs.Color final static

White color