Class: Color

Oracle® JavaScript Extension Toolkit (JET)
7.1.0

F18183-01

QuickNav

Fields


Color

Version:
  • 7.1.0
Since:
  • 3.0.0
Module:
  • ojcolor

Module usage

See JET Module Loading for an overview of module usage within JET.

Javascript Import Format
define(['ojs/ojcolor'], function(Color) {
 // Application should call API on Color 
})
Typescript Import Format
//This class is exported directly as module. To import it
import Color= require("ojs/ojcolor");

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.

Description

Immutable object representing a color.

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 oj.Color constants (e.g. oj.Color.ALICEBLUE)
Parameters:
Name Type Description
color string | oj.Color.RGBA | oj.Color.HSLA | oj.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 :oj.Color

CSS3 color aliceblue

(static) ANTIQUEWHITE :oj.Color

CSS3 color antiquewhite

(static) AQUA :oj.Color

CSS3 color aqua

(static) AQUAMARINE :oj.Color

CSS3 color aquamarine

(static) AZURE :oj.Color

CSS3 color azure

(static) BEIGE :oj.Color

CSS3 color beige

(static) BISQUE :oj.Color

CSS3 color bisque

(static) BLACK :oj.Color

CSS3 color black

(static) BLANCHEDALMOND :oj.Color

CSS3 color blanchedalmond

(static) BLUE :oj.Color

CSS3 color blue

(static) BLUEVIOLET :oj.Color

CSS3 color blueviolet

(static) BROWN :oj.Color

CSS3 color brown

(static) BURLYWOOD :oj.Color

CSS3 color burlywood

(static) CADETBLUE :oj.Color

CSS3 color cadetblue

(static) CHARTREUSE :oj.Color

CSS3 color chartreuse

(static) CHOCOLATE :oj.Color

CSS3 color chocolate

(static) CORAL :oj.Color

CSS3 color coral

(static) CORNFLOWERBLUE :oj.Color

CSS3 color cornflowerblue

(static) CORNSILK :oj.Color

CSS3 color cornsilk

(static) CRIMSON :oj.Color

CSS3 color crimson

(static) CYAN :oj.Color

CSS3 color cyan

(static) DARKBLUE :oj.Color

CSS3 color darkblue

(static) DARKCYAN :oj.Color

CSS3 color darkcyan

(static) DARKGOLDENROD :oj.Color

CSS3 color darkgoldenrod

(static) DARKGRAY :oj.Color

CSS3 color darkgray

(static) DARKGREEN :oj.Color

CSS3 color darkgreen

(static) DARKGREY :oj.Color

CSS3 color darkgrey

(static) DARKKHAKI :oj.Color

CSS3 color darkkhaki

(static) DARKMAGENTA :oj.Color

CSS3 color darkmagenta

(static) DARKOLIVEGREEN :oj.Color

CSS3 color darkolivegreen

(static) DARKORANGE :oj.Color

CSS3 color darkorange

(static) DARKORCHID :oj.Color

CSS3 color darkorchid

(static) DARKRED :oj.Color

CSS3 color darkred

(static) DARKSALMON :oj.Color

CSS3 color darksalmon

(static) DARKSEAGREEN :oj.Color

CSS3 color darkseagreen

(static) DARKSLATEBLUE :oj.Color

CSS3 color darkslateblue

(static) DARKSLATEGRAY :oj.Color

CSS3 color darkslategray

(static) DARKSLATEGREY :oj.Color

CSS3 color darkslategrey

(static) DARKTURQUOISE :oj.Color

CSS3 color darkturquoise

(static) DARKVIOLET :oj.Color

CSS3 color darkviolet

(static) DEEPPINK :oj.Color

CSS3 color deeppink

(static) DEEPSKYBLUE :oj.Color

CSS3 color deepskyblue

(static) DIMGRAY :oj.Color

CSS3 color dimgray

(static) DIMGREY :oj.Color

CSS3 color dimgrey

(static) DODGERBLUE :oj.Color

CSS3 color dodgerblue

(static) FIREBRICK :oj.Color

CSS3 color firebrick

(static) FLORALWHITE :oj.Color

CSS3 color floralwhite

(static) FORESTGREEN :oj.Color

CSS3 color forestgreen

(static) FUCHSIA :oj.Color

CSS3 color fuchsia

(static) GAINSBORO :oj.Color

CSS3 color gainsboro

(static) GHOSTWHITE :oj.Color

CSS3 color ghostwhite

(static) GOLD :oj.Color

CSS3 color gold

(static) GOLDENROD :oj.Color

CSS3 color goldenrod

(static) GRAY :oj.Color

CSS3 color gray

(static) GREEN :oj.Color

CSS3 color green

(static) GREENYELLOW :oj.Color

CSS3 color greenyellow

(static) GREY :oj.Color

CSS3 color grey

(static) HONEYDEW :oj.Color

CSS3 color honeydew

(static) HOTPINK :oj.Color

CSS3 color hotpink

(static) INDIANRED :oj.Color

CSS3 color indianred

(static) INDIGO :oj.Color

CSS3 color indigo

(static) IVORY :oj.Color

CSS3 color ivory

(static) KHAKI :oj.Color

CSS3 color khaki

(static) LAVENDER :oj.Color

CSS3 color lavender

(static) LAVENDERBLUSH :oj.Color

CSS3 color lavenderblush

(static) LAWNGREEN :oj.Color

CSS3 color lawngreen

(static) LEMONCHIFFON :oj.Color

CSS3 color lemonchiffon

(static) LIGHTBLUE :oj.Color

CSS3 color lightblue

(static) LIGHTCORAL :oj.Color

CSS3 color lightcoral

(static) LIGHTCYAN :oj.Color

CSS3 color lightcyan

(static) LIGHTGOLDENRODYELLOW :oj.Color

CSS3 color lightgoldenrodyellow

(static) LIGHTGRAY :oj.Color

CSS3 color lightgray

(static) LIGHTGREEN :oj.Color

CSS3 color lightgreen

(static) LIGHTGREY :oj.Color

CSS3 color lightgrey

(static) LIGHTPINK :oj.Color

CSS3 color lightpink

(static) LIGHTSALMON :oj.Color

CSS3 color lightsalmon

(static) LIGHTSEAGREEN :oj.Color

CSS3 color lightseagreen

(static) LIGHTSKYBLUE :oj.Color

CSS3 color lightskyblue

(static) LIGHTSLATEGRAY :oj.Color

CSS3 color lightslategray

(static) LIGHTSLATEGREY :oj.Color

CSS3 color lightslategrey

(static) LIGHTSTEELBLUE :oj.Color

CSS3 color lightsteelblue

(static) LIGHTYELLOW :oj.Color

CSS3 color lightyellow

(static) LIME :oj.Color

CSS3 color lime

(static) LIMEGREEN :oj.Color

CSS3 color limegreen

(static) LINEN :oj.Color

CSS3 color linen

(static) MAGENTA :oj.Color

CSS3 color magenta

(static) MAROON :oj.Color

CSS3 color maroon

(static) MEDIUMAQUAMARINE :oj.Color

CSS3 color mediumaquamarine

(static) MEDIUMBLUE :oj.Color

CSS3 color mediumblue

(static) MEDIUMORCHID :oj.Color

CSS3 color mediumorchid

(static) MEDIUMPURPLE :oj.Color

CSS3 color mediumpurple

(static) MEDIUMSEAGREEN :oj.Color

CSS3 color mediumseagreen

(static) MEDIUMSLATEBLUE :oj.Color

CSS3 color mediumslateblue

(static) MEDIUMSPRINGGREEN :oj.Color

CSS3 color mediumspringgreen

(static) MEDIUMTURQUOISE :oj.Color

CSS3 color mediumturquoise

(static) MEDIUMVIOLETRED :oj.Color

CSS3 color mediumvioletred

(static) MIDNIGHTBLUE :oj.Color

CSS3 color midnightblue

(static) MINTCREAM :oj.Color

CSS3 color mintcream

(static) MISTYROSE :oj.Color

CSS3 color mistyrose

(static) MOCCASIN :oj.Color

CSS3 color moccasin
CSS3 color navajowhite
CSS3 color navy

(static) OLDLACE :oj.Color

CSS3 color oldlace

(static) OLIVE :oj.Color

CSS3 color olive

(static) OLIVEDRAB :oj.Color

CSS3 color olivedrab

(static) ORANGE :oj.Color

CSS3 color orange

(static) ORANGERED :oj.Color

CSS3 color orangered

(static) ORCHID :oj.Color

CSS3 color orchid

(static) PALEGOLDENROD :oj.Color

CSS3 color palegoldenrod

(static) PALEGREEN :oj.Color

CSS3 color palegreen

(static) PALETURQUOISE :oj.Color

CSS3 color paleturquoise

(static) PALEVIOLETRED :oj.Color

CSS3 color palevioletred

(static) PAPAYAWHIP :oj.Color

CSS3 color papayawhip

(static) PEACHPUFF :oj.Color

CSS3 color peachpuff

(static) PERU :oj.Color

CSS3 color peru

(static) PINK :oj.Color

CSS3 color pink

(static) PLUM :oj.Color

CSS3 color plum

(static) POWDERBLUE :oj.Color

CSS3 color powderblue

(static) PURPLE :oj.Color

CSS3 color purple

(static) REBECCAPURPLE :oj.Color

CSS3 color rebeccapurple

(static) RED :oj.Color

CSS3 color red

(static) ROSYBROWN :oj.Color

CSS3 color rosybrown

(static) ROYALBLUE :oj.Color

CSS3 color royalblue

(static) SADDLEBROWN :oj.Color

CSS3 color saddlebrown

(static) SALMON :oj.Color

CSS3 color salmon

(static) SANDYBROWN :oj.Color

CSS3 color sandybrown

(static) SEAGREEN :oj.Color

CSS3 color seagreen

(static) SEASHELL :oj.Color

CSS3 color seashell

(static) SIENNA :oj.Color

CSS3 color sienna

(static) SILVER :oj.Color

CSS3 color silver

(static) SKYBLUE :oj.Color

CSS3 color skyblue

(static) SLATEBLUE :oj.Color

CSS3 color slateblue

(static) SLATEGRAY :oj.Color

CSS3 color slategray

(static) SLATEGREY :oj.Color

CSS3 color slategrey

(static) SNOW :oj.Color

CSS3 color snow

(static) SPRINGGREEN :oj.Color

CSS3 color springgreen

(static) STEELBLUE :oj.Color

CSS3 color steelblue

(static) TAN :oj.Color

CSS3 color tan

(static) TEAL :oj.Color

CSS3 color teal

(static) THISTLE :oj.Color

CSS3 color thistle

(static) TOMATO :oj.Color

CSS3 color tomato

(static) TRANSPARENT :oj.Color

CSS3 color transparent

(static) TURQUOISE :oj.Color

CSS3 color turquoise

(static) VIOLET :oj.Color

CSS3 color violet

(static) WHEAT :oj.Color

CSS3 color wheat

(static) WHITE :oj.Color

CSS3 color white

(static) WHITESMOKE :oj.Color

CSS3 color whitesmoke

(static) YELLOW :oj.Color

CSS3 color yellow

(static) YELLOWGREEN :oj.Color

CSS3 color yellowgreen

Methods

getAlpha() → {number}

Returns the alpha channel of the color.
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.)
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.)
Returns:
The green channel value contained in [0,255].
Type
number

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.)
Returns:
The red channel value in the range [0,255].
Type
number

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 oj.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
h number the hue value
s number the saturation value
l number the luminosity or lightness value
a number <optional>
the optional alpha value

HSVA

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

RGBA

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