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 |
Classes
Members
(static) Amaranth
(static) Amber
(static) Amethyst
(static) BabyBlue
(static) BananaYellow
(static) BitterLemon
(static) BitterLime
(static) Bittersweet
(static) Black
0, 0, 0
(static) BlackCoffee
(static) Blue
0, 0, 255
(static) Burgundy
(static) Camouflage
(static) CardboardBrown
(static) Carmine
(static) Champagne
(static) Charcoal
(static) CherryBlossom
(static) ChromeYellow
(static) Cobalt
(static) Copper
(static) Coral
(static) Cornflower
(static) Crimson
(static) Cyan
0, 255, 255
(static) Dandelion
(static) DarkBlue
(static) DarkViolet
(static) Eggplant
(static) Emerald
(static) FrenchRose
(static) Fuchsia
(static) FuchsiaRose
(static) GrassGreen
96, 117, 76
(static) Green
0, 255, 0
(static) LightBlue
(static) LightGray
(static) Magenta
255, 0, 255
(static) Mango
(static) MetallicGold
(static) Mint
(static) OldPaper
(static) Orange
(static) OrchidViolet
(static) PastellGreen
(static) PastellLightViolet
(static) PastellRed
172, 51, 53
(static) PastellViolet
(static) PastellYellow
(static) Pink
(static) PinkPantone
(static) Plum
(static) Red
255, 0, 0
(static) Transparent
0, 0, 0, 0
(static) White
255, 255, 255
(static) Yellow
255, 255, 0
a
The alpha value of the color
array
Returns the color components as an array.
b
The blue value of the color
css
Returns the color as a CSS color string.
g
The green value of the color
r
The red value of the color
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 |
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 |
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 |
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 |
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 |
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 |
(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 |
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 |
Returns:
- Type
- Color
(static) random() → {Color}
Generate a random color
Returns:
the random color value.
- Type
- Color
asCss() → {string}
Returns the color as a CSS color string.
Returns:
- the css rgba() color string
- Type
- string