Final Class: Color

Oracle® JavaScript Extension Toolkit (JET)
17.1.0

G12196-01

Since:
  • 3.0.0
Module:
  • ojcolor

QuickNav

Fields

Description

Immutable object representing a color.


Usage

Typescript Import Format
//This class is exported directly as module. To import it
import Color= require("ojs/ojcolor");

For additional information visit:


Final classes in JET

Classes in JET are generally final and do not support subclassing. At the moment, final is not enforced. However, this will likely change in an upcoming JET release.


Constructor

new Color(color)

Creates an object representing a color. The color may be defined using the RGB, HSL, and HSV model values as an object, or as a CSS3 color specification string (refer to https://developer.mozilla.org/en-US/docs/Web/CSS/color_value, and also https://www.w3.org/TR/css3-color/#svg-color for color visualization. The CSS3 named colors are available as Color constants (e.g. Color.ALICEBLUE)
Parameters:
Name Type Description
color string | Color.RGBA | Color.HSLA | Color.HSVA
  • A valid CSS3 color specification string (refer to https://developer.mozilla.org/en-US/docs/Web/CSS/color_value for syntax)
  • An object containing one of the following groups of fields:
    • r:   the red value
    • g:   the green value
    • b:   the blue value
    • a:   the alpha value (optional)

    • h:   the hue value
    • s:   the saturation value
    • l:   the luminosity or lightness value
    • a:   the alpha value (optional)

    • h:   the hue value
    • s:   the saturation value
    • v:   the value
    • a:   the alpha value (optional)
Throws:
if the color specification cannot be parsed correctly.
Type
Error

Fields

(static) ALICEBLUE :Color

CSS3 color aliceblue

(static) ANTIQUEWHITE :Color

CSS3 color antiquewhite

(static) AQUA :Color

CSS3 color aqua

(static) AQUAMARINE :Color

CSS3 color aquamarine

(static) AZURE :Color

CSS3 color azure

(static) BEIGE :Color

CSS3 color beige

(static) BISQUE :Color

CSS3 color bisque

(static) BLACK :Color

CSS3 color black

(static) BLANCHEDALMOND :Color

CSS3 color blanchedalmond

(static) BLUE :Color

CSS3 color blue

(static) BLUEVIOLET :Color

CSS3 color blueviolet

(static) BROWN :Color

CSS3 color brown

(static) BURLYWOOD :Color

CSS3 color burlywood

(static) CADETBLUE :Color

CSS3 color cadetblue

(static) CHARTREUSE :Color

CSS3 color chartreuse

(static) CHOCOLATE :Color

CSS3 color chocolate

(static) CORAL :Color

CSS3 color coral

(static) CORNFLOWERBLUE :Color

CSS3 color cornflowerblue

(static) CORNSILK :Color

CSS3 color cornsilk

(static) CRIMSON :Color

CSS3 color crimson

(static) CYAN :Color

CSS3 color cyan

(static) DARKBLUE :Color

CSS3 color darkblue

(static) DARKCYAN :Color

CSS3 color darkcyan

(static) DARKGOLDENROD :Color

CSS3 color darkgoldenrod

(static) DARKGRAY :Color

CSS3 color darkgray

(static) DARKGREEN :Color

CSS3 color darkgreen

(static) DARKGREY :Color

CSS3 color darkgrey

(static) DARKKHAKI :Color

CSS3 color darkkhaki

(static) DARKMAGENTA :Color

CSS3 color darkmagenta

(static) DARKOLIVEGREEN :Color

CSS3 color darkolivegreen

(static) DARKORANGE :Color

CSS3 color darkorange

(static) DARKORCHID :Color

CSS3 color darkorchid

(static) DARKRED :Color

CSS3 color darkred

(static) DARKSALMON :Color

CSS3 color darksalmon

(static) DARKSEAGREEN :Color

CSS3 color darkseagreen

(static) DARKSLATEBLUE :Color

CSS3 color darkslateblue

(static) DARKSLATEGRAY :Color

CSS3 color darkslategray

(static) DARKSLATEGREY :Color

CSS3 color darkslategrey

(static) DARKTURQUOISE :Color

CSS3 color darkturquoise

(static) DARKVIOLET :Color

CSS3 color darkviolet

(static) DEEPPINK :Color

CSS3 color deeppink

(static) DEEPSKYBLUE :Color

CSS3 color deepskyblue

(static) DIMGRAY :Color

CSS3 color dimgray

(static) DIMGREY :Color

CSS3 color dimgrey

(static) DODGERBLUE :Color

CSS3 color dodgerblue

(static) FIREBRICK :Color

CSS3 color firebrick

(static) FLORALWHITE :Color

CSS3 color floralwhite

(static) FORESTGREEN :Color

CSS3 color forestgreen

(static) FUCHSIA :Color

CSS3 color fuchsia

(static) GAINSBORO :Color

CSS3 color gainsboro

(static) GHOSTWHITE :Color

CSS3 color ghostwhite

(static) GOLD :Color

CSS3 color gold

(static) GOLDENROD :Color

CSS3 color goldenrod

(static) GRAY :Color

CSS3 color gray

(static) GREEN :Color

CSS3 color green

(static) GREENYELLOW :Color

CSS3 color greenyellow

(static) GREY :Color

CSS3 color grey

(static) HONEYDEW :Color

CSS3 color honeydew

(static) HOTPINK :Color

CSS3 color hotpink

(static) INDIANRED :Color

CSS3 color indianred

(static) INDIGO :Color

CSS3 color indigo

(static) IVORY :Color

CSS3 color ivory

(static) KHAKI :Color

CSS3 color khaki

(static) LAVENDER :Color

CSS3 color lavender

(static) LAVENDERBLUSH :Color

CSS3 color lavenderblush

(static) LAWNGREEN :Color

CSS3 color lawngreen

(static) LEMONCHIFFON :Color

CSS3 color lemonchiffon

(static) LIGHTBLUE :Color

CSS3 color lightblue

(static) LIGHTCORAL :Color

CSS3 color lightcoral

(static) LIGHTCYAN :Color

CSS3 color lightcyan

(static) LIGHTGOLDENRODYELLOW :Color

CSS3 color lightgoldenrodyellow

(static) LIGHTGRAY :Color

CSS3 color lightgray

(static) LIGHTGREEN :Color

CSS3 color lightgreen

(static) LIGHTGREY :Color

CSS3 color lightgrey

(static) LIGHTPINK :Color

CSS3 color lightpink

(static) LIGHTSALMON :Color

CSS3 color lightsalmon

(static) LIGHTSEAGREEN :Color

CSS3 color lightseagreen

(static) LIGHTSKYBLUE :Color

CSS3 color lightskyblue

(static) LIGHTSLATEGRAY :Color

CSS3 color lightslategray

(static) LIGHTSLATEGREY :Color

CSS3 color lightslategrey

(static) LIGHTSTEELBLUE :Color

CSS3 color lightsteelblue

(static) LIGHTYELLOW :Color

CSS3 color lightyellow

(static) LIME :Color

CSS3 color lime

(static) LIMEGREEN :Color

CSS3 color limegreen

(static) LINEN :Color

CSS3 color linen

(static) MAGENTA :Color

CSS3 color magenta

(static) MAROON :Color

CSS3 color maroon

(static) MEDIUMAQUAMARINE :Color

CSS3 color mediumaquamarine

(static) MEDIUMBLUE :Color

CSS3 color mediumblue

(static) MEDIUMORCHID :Color

CSS3 color mediumorchid

(static) MEDIUMPURPLE :Color

CSS3 color mediumpurple

(static) MEDIUMSEAGREEN :Color

CSS3 color mediumseagreen

(static) MEDIUMSLATEBLUE :Color

CSS3 color mediumslateblue

(static) MEDIUMSPRINGGREEN :Color

CSS3 color mediumspringgreen

(static) MEDIUMTURQUOISE :Color

CSS3 color mediumturquoise

(static) MEDIUMVIOLETRED :Color

CSS3 color mediumvioletred

(static) MIDNIGHTBLUE :Color

CSS3 color midnightblue

(static) MINTCREAM :Color

CSS3 color mintcream

(static) MISTYROSE :Color

CSS3 color mistyrose

(static) MOCCASIN :Color

CSS3 color moccasin
CSS3 color navajowhite
CSS3 color navy

(static) OLDLACE :Color

CSS3 color oldlace

(static) OLIVE :Color

CSS3 color olive

(static) OLIVEDRAB :Color

CSS3 color olivedrab

(static) ORANGE :Color

CSS3 color orange

(static) ORANGERED :Color

CSS3 color orangered

(static) ORCHID :Color

CSS3 color orchid

(static) PALEGOLDENROD :Color

CSS3 color palegoldenrod

(static) PALEGREEN :Color

CSS3 color palegreen

(static) PALETURQUOISE :Color

CSS3 color paleturquoise

(static) PALEVIOLETRED :Color

CSS3 color palevioletred

(static) PAPAYAWHIP :Color

CSS3 color papayawhip

(static) PEACHPUFF :Color

CSS3 color peachpuff

(static) PERU :Color

CSS3 color peru

(static) PINK :Color

CSS3 color pink

(static) PLUM :Color

CSS3 color plum

(static) POWDERBLUE :Color

CSS3 color powderblue

(static) PURPLE :Color

CSS3 color purple

(static) REBECCAPURPLE :Color

CSS3 color rebeccapurple

(static) RED :Color

CSS3 color red

(static) ROSYBROWN :Color

CSS3 color rosybrown

(static) ROYALBLUE :Color

CSS3 color royalblue

(static) SADDLEBROWN :Color

CSS3 color saddlebrown

(static) SALMON :Color

CSS3 color salmon

(static) SANDYBROWN :Color

CSS3 color sandybrown

(static) SEAGREEN :Color

CSS3 color seagreen

(static) SEASHELL :Color

CSS3 color seashell

(static) SIENNA :Color

CSS3 color sienna

(static) SILVER :Color

CSS3 color silver

(static) SKYBLUE :Color

CSS3 color skyblue

(static) SLATEBLUE :Color

CSS3 color slateblue

(static) SLATEGRAY :Color

CSS3 color slategray

(static) SLATEGREY :Color

CSS3 color slategrey

(static) SNOW :Color

CSS3 color snow

(static) SPRINGGREEN :Color

CSS3 color springgreen

(static) STEELBLUE :Color

CSS3 color steelblue

(static) TAN :Color

CSS3 color tan

(static) TEAL :Color

CSS3 color teal

(static) THISTLE :Color

CSS3 color thistle

(static) TOMATO :Color

CSS3 color tomato

(static) TRANSPARENT :Color

CSS3 color transparent

(static) TURQUOISE :Color

CSS3 color turquoise

(static) VIOLET :Color

CSS3 color violet

(static) WHEAT :Color

CSS3 color wheat

(static) WHITE :Color

CSS3 color white

(static) WHITESMOKE :Color

CSS3 color whitesmoke

(static) YELLOW :Color

CSS3 color yellow

(static) YELLOWGREEN :Color

CSS3 color yellowgreen

Methods

getAlpha : {number}

Returns the alpha channel of the color.
Deprecated:
Since Description
12.0.0 Use the getRGBA,getHSLA,getHSVA method instead for fetching color value in different format.
Returns:

The alpha channel value contained in [0,1].

Type
number

getBlue(doNotRound) : {number}

Returns the blue channel value of the color.
Parameters:
Name Type Argument Description
doNotRound boolean <optional>
Omit or set to false to return an integer value. Set to true to return the possible fractional value. (Fractional values for the red, green, or blue channels can arise when a color is defined using the "hsl" format.)
Deprecated:
Since Description
12.0.0 Use the getRGBA,getHSLA,getHSVA method instead for fetching color value in different format.
Returns:

The blue channel value contained in [0,255].

Type
number

getGreen(doNotRound) : {number}

Returns the green channel value of the color.
Parameters:
Name Type Argument Description
doNotRound boolean <optional>
Omit or set to false to return an integer value. Set to true to return the possible fractional value. (Fractional values for the red, green, or blue channels can arise when a color is defined using the "hsl" format.)
Deprecated:
Since Description
12.0.0 Use the getRGBA,getHSLA,getHSVA method instead for fetching color value in different format.
Returns:

The green channel value contained in [0,255].

Type
number

getHSLA : {Color.HSLA}

Returns the red channel value of the color arise when a color is defined using the "hsl" format.)
Returns:

The HSLA value in the range [0,255].

Type
Color.HSLA

getHSVA : {Color.HSVA}

Returns the red channel value of the color arise when a color is defined using the "hsl" format.)
Returns:

The HSLA value in the range [0,255].

Type
Color.HSVA

getRed(doNotRound) : {number}

} /** Returns the red channel value of the color.
Parameters:
Name Type Argument Description
doNotRound boolean <optional>
Omit or set to false to return an integer value. Set to true to return the possible fractional value. (Fractional values for the red, green, or blue channels can arise when a color is defined using the "hsl" format.)
Deprecated:
Since Description
12.0.0 Use the getRGBA,getHSLA,getHSVA method instead for fetching color value in different format.
Returns:

The red channel value in the range [0,255].

Type
number

getRGBA : {Color.RGBA}

Returns the red channel value of the color arise when a color is defined using the "hsl" format.)
Returns:

The RGBA value in the range [0,255].

Type
Color.RGBA

isEqual(color) : {boolean}

Compares this color object with the supplied color specification, and returns true if they represent the same color, else false.
Parameters:
Name Type Description
color Color The color to be compared.
Returns:

Returns true if the comperand represents the same color.

Type
boolean

toString : {string}

Returns the color as an "rgb" or rgba" (if the alpha value is less than 1) CSS3 color specification string.
Returns:

The color as an "rgb" or "rgba" CSS3 color specification string.

Type
string

Type Definitions

HSLA

Properties:
Name Type Argument Description
a number <optional>
the optional alpha value
h number the hue value
l number the luminosity or lightness value
s number the saturation value

HSVA

Properties:
Name Type Argument Description
a number <optional>
the optional alpha value
h number the hue value
s number the saturation value
v number the value

RGBA

Properties:
Name Type Argument Description
a number <optional>
the optional alpha value
b number the blue value
g number the green value
r number the red value