ColorGradient

Used to hold Color values in a gradient form. Colors can be added to the gradient at specific points from 0 to 1, and they (along with the colors in between) can be retrieved at specified points.

Constructor

new ColorGradient(values, snap)

Create a new ColorGradient.
Parameters:
NameTypeDefaultDescription
valuesObject.<number, Color>Initial values of gradient
snapbooleanfalse(Optional) Whether the get() function should return interpolated values between the colors (false), or snap to the color at the closest lower point (true). Set to false by default.

Methods

get(point) → {Color}

Get the color on the gradient at a specified point.
Parameters:
NameTypeDescription
pointnumberPoint along the gradient (0-1)
Returns:
Resulting color at the specified point along the gradient
Type: 
Color

set(point, color)

Set a Color at a point
Parameters:
NameTypeDescription
pointnumberPoint to set the color at (0-1)
colorColorColor to set at the point