Constructor
new Palette(colors)
Create a palette from an array of Color objects
Parameters:
| Name | Type | Description |
|---|---|---|
colors |
Array.<Color> | array of Color objects |
- Source:
Members
colors
Get all colors in the palette
- Source:
length
Get the number of colors in the palette
- Source:
Methods
copy() → {Palette}
Return a copy of the palette
- Source:
Returns:
copy of the palette
- Type
- Palette
getColor(i) → {Color}
Get the color at index i. The index wraps around if it exceeds the number of colors
Parameters:
| Name | Type | Description |
|---|---|---|
i |
number | index of the color |
- Source:
Returns:
color at index i
- Type
- Color
getRandomColor(rand) → {Color}
Get a random color from the palette
Parameters:
| Name | Type | Description |
|---|---|---|
rand |
RandomClass | random number generator with a random() method. Defaults to Math |
- Source:
Returns:
random color from the palette
- Type
- Color
getSmoothColor(t, easing) → {Color}
Get a smoothly interpolated color from the palette
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
t |
number | value between 0 and 1 | |
easing |
EasingFunction | null | null | easing function to use for the interpolation. Defaults to null (linear) |
- Source:
Returns:
smoothly interpolated color from the palette
- Type
- Color
reverse() → {Palette}
Reverts the order of colors in the palette
- Source:
Returns:
inverted palette
- Type
- Palette
rotate(n) → {Palette}
Rotate the colors in the palette by n positions
Parameters:
| Name | Type | Description |
|---|---|---|
n |
number | number of positions to rotate |
- Source:
Returns:
rotated palette
- Type
- Palette
shuffle(rand) → {Palette}
Shuffle the colors in the palette
Parameters:
| Name | Type | Description |
|---|---|---|
rand |
RandomClass | random number generator with a random() method. Defaults to Math |
- Source:
Returns:
shuffled palette
- Type
- Palette
(static) fromCMYKArray(colors) → {Palette}
Create a palette from an array of CMYK color arrays
Parameters:
| Name | Type | Description |
|---|---|---|
colors |
Array.<Array.<number>> | array of CMYK color arrays |
- Source:
Returns:
palette object
- Type
- Palette
(static) fromHEXArray(colors) → {Palette}
Create a palette from an array of HEX color strings
Parameters:
| Name | Type | Description |
|---|---|---|
colors |
Array.<string> | array of HEX color strings |
- Source:
Returns:
palette object
- Type
- Palette
(static) fromHSLArray(colors) → {Palette}
Create a palette from an array of HSL color arrays
Parameters:
| Name | Type | Description |
|---|---|---|
colors |
Array.<Array.<number>> | array of HSL color arrays |
- Source:
Returns:
palette object
- Type
- Palette
(static) fromRGBArray(colors) → {Palette}
Create a palette from an array of RGB color arrays
Parameters:
| Name | Type | Description |
|---|---|---|
colors |
Array.<Array.<number>> | array of RGB color arrays |
- Source:
Returns:
palette object
- Type
- Palette
(static) fromSanzoWadaArray(colors) → {Palette}
Create a palette from an array of Sanzo Wada color arrays
Parameters:
| Name | Type | Description |
|---|---|---|
colors |
Array.<Array.<string>> | array of Sanzo Wada color arrays |
- Source:
Returns:
palette object
- Type
- Palette