Class: Color

Color(r, g, b, a)

Utility class for manipulating RGBA colors. Color is a simple color class composed of 4 components: - Red - Green - Blue - Alpha (opacity) Each component is a public member, an integer in the range 0 to 255

Constructor

new Color(r, g, b, a)

Create a new color from R, G, B and A components in the range of 0 to 255.
Parameters:
Name Type Default Description
r number red value
g number green value
b number blue value
a number 255 alpha (opacity) value
Source:

Classes

Color

Members

(static) Amaranth

Source:

(static) Amber

Source:

(static) Amethyst

Source:

(static) BabyBlue

Source:

(static) BananaYellow

Source:

(static) BitterLemon

Source:

(static) BitterLime

Source:

(static) Bittersweet

Source:

(static) Black

0, 0, 0
Source:

(static) BlackCoffee

Source:

(static) Blue

0, 0, 255
Source:

(static) Burgundy

Source:

(static) Camouflage

Source:

(static) CardboardBrown

Source:

(static) Carmine

Source:

(static) Champagne

Source:

(static) Charcoal

Source:

(static) CherryBlossom

Source:

(static) ChromeYellow

Source:

(static) Cobalt

Source:

(static) Copper

Source:

(static) Coral

Source:

(static) Cornflower

Source:

(static) Crimson

Source:

(static) Cyan

0, 255, 255
Source:

(static) Dandelion

Source:

(static) DarkBlue

Source:

(static) DarkViolet

Source:

(static) Eggplant

Source:

(static) Emerald

Source:

(static) FrenchRose

Source:

(static) Fuchsia

Source:

(static) FuchsiaRose

Source:

(static) GrassGreen

96, 117, 76
Source:

(static) Green

0, 255, 0
Source:

(static) LightBlue

Source:

(static) LightGray

Source:

(static) Magenta

255, 0, 255
Source:

(static) Mango

Source:

(static) MetallicGold

Source:

(static) Mint

Source:

(static) OldPaper

Source:

(static) Orange

Source:

(static) OrchidViolet

Source:

(static) PastellGreen

Source:

(static) PastellLightViolet

Source:

(static) PastellRed

172, 51, 53
Source:

(static) PastellViolet

Source:

(static) PastellYellow

Source:

(static) Pink

Source:

(static) PinkPantone

Source:

(static) Plum

Source:

(static) Red

255, 0, 0
Source:

(static) Transparent

0, 0, 0, 0
Source:

(static) White

255, 255, 255
Source:

(static) Yellow

255, 255, 0
Source:

a

The alpha value of the color
Source:

array

Returns the color components as an array.
Source:

b

The blue value of the color
Source:

css

Returns the color as a CSS color string.
Source:

g

The green value of the color
Source:

r

The red value of the color
Source:

Methods

(static) fromBytes(r, g, b, a) → {Color}

Creates a color from integers. Expectes the integers to be in the range from 0 to 255.
Parameters:
Name Type Description
r number red value
g number green value
b number blue value
a number alpha value
Source:
Returns:
- the color
Type
Color

(static) fromFloats(r, g, b, a) → {Color}

Creates a color from floats. Expects the floats to be in the range from 0.0 to 1.0.
Parameters:
Name Type Description
r number red value
g number green value
b number blue value
a number alpha value
Source:
Returns:
- the color
Type
Color

(static) fromHex(hex) → {Color}

Creates a color from a hex value
Parameters:
Name Type Description
hex number the hex color value in the format 0xrrggbbaa
Source:
Returns:
- the color
Type
Color

(static) fromHexStr(hexStr) → {Color}

Creates a color from a hex string value.
Parameters:
Name Type Description
hexStr string the hex color string in the format 0xrrggbbaa
Source:
Returns:
Type
Color

(static) fromHsl(h, s, l) → {Color}

Creates a color from an HSL color value. Assumes h, s and l are in the range of 0 to 1
Parameters:
Name Type Description
h number hue
s number saturation
l number luminance
Source:
Returns:
- the color
Type
Color

(static) fromHsl8(h, s, l)

Creates a color from an HSL color value. Assumes h, s and l are in the range of 0 to 359 and 0 to 100.
Parameters:
Name Type Description
h number hue
s number saturation
l number luminance
Source:

(static) fromRgba(r, g, b, a) → {Color}

Create a color from floats. Expects the floats to be in the range of 0.0 to 1.0.
Parameters:
Name Type Description
r number the red value
g number the green value
b number the blue value
a number the alpha value
Source:
Returns:
Type
Color

(static) fromRgba8(r, g, b, a) → {Color}

Creates a color from integers. Expects the integers to be in the range of 0 to 255.
Parameters:
Name Type Description
r number the red value
g number the green value
b number the blue value
a number the alpha value
Source:
Returns:
Type
Color

(static) random() → {Color}

Generate a random color
Source:
Returns:
the random color value.
Type
Color

asCss() → {string}

Returns the color as a CSS color string.
Source:
Returns:
- the css rgba() color string
Type
string