new ColorPalette(opt_id=)
Creates a new ColorPalette object.
Use this class to create a palette of colors randomly selected
from a range created with initial start and end colors. You
can also generate gradients that smoothly interpolate from
start and end colors.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
opt_id= |
string | number |
<optional> |
An optional id. If an id is not passed, a default id is created. |
- Source:
Members
-
<private, static> _idCount :number
-
Increments as each ColorPalette is created.
Type:
- number
- Default Value:
- 0
- Source:
-
<private> _colors
-
Holds a list of arrays representing 3-digit color values randomly selected from start and end colors.
- Source:
-
<private> _gradients
-
Holds a list of arrays representing 3-digit color values smoothly interpolated between start and end colors.
- Source:
Methods
-
<static> _createColorRange(startColor, startColor, totalColors) → {Array}
-
Creates an array of RGB color values interpolated between a passed startColor and endColor.
Parameters:
Name Type Description startColor
Array The beginning of the color array. startColor
Array The end of the color array. totalColors
number The total numnber of colors to create. - Source:
Returns:
An array of color values.- Type
- Array
-
addColor(options)
-
Creates a color range of 255 colors from the passed start and end colors. Adds a random selection of these colors to the color property of the color palette.
Parameters:
Name Type Description options
Object A set of required options that includes: options.min {number} The minimum number of colors to add. options.max {number} The maximum number of color to add. options.startColor {Array} The beginning color of the color range. options.endColor {Array} The end color of the color range. - Source:
-
getColor()
-
- Source:
Throws:
-
If the colors property is empty.
- Type
- Error
Returns:
An array representing a randomly selected color from the colors property.