Class: rlPalette

rlPalette

new rlPalette(paletteName, namedColors, colNameCodePairsopt)

Instantiates a named palette with a given array of named colors and adds each of those colors as a property of the same name to itself, as well as linking the color to an index number, so a color in the palette can be accessed by both its name and by its index. Also initializes red, green and blue componenents from the given htmlCode of each named color. So, a color in the palette is accessed as e.g. p["black"] or p[0] and each color in the palette has the properties: name, index, htmlCode, r, g and b

Parameters:
Name Type Attributes Description
paletteName string

the name of the palette

namedColors Array.<rlPalette.namedColor> | null

the array of color definitions to put into the palette (set to null to use the following parameter instead)

colNameCodePairs string <optional>

comma separated string with pairs of names and htmlcodes of colors eg. "black#000000,white#FFFFFF" (ignored if namedColors is used)

Members

length

Properties:
Name Type Description
length number

the number of colors stored inside the palette

name

Properties:
Name Type Description
name string

the name of the palette

Methods

getColor() → {rlPalette.namedColor}

Get a color by its name or index (same as using this[nameOrIndex] ).

Properties:
Name Type Description
nameOrIndex string | number

e.g. "white" or 15

Returns:

the requested palette entry

Type
rlPalette.namedColor

Type Definitions

namedColor

(not an actual type, use object literals with these properties)

Properties:
Name Type Attributes Default Description
name string

the name to use for the color, e.g. "fullWhite"

htmlCode string

the html code defining the color, e.g. "#FFFFFF"

r number <optional>
converted from htmlCode

the red component of a palette entry

g number <optional>
converted from htmlCode

the green component of a palette entry

b number <optional>
converted from htmlCode

the blue component of a palette entry