LinearGradient

A linear gradient with a start and end point and color stops.

Constructor

new LinearGradient(p1, p2, color_stops)

Creates a new LinearGradient with the given start point, end point, and ColorStops.

Parameters:
NameTypeDescription
p1Point2D

The start point of the gradient.

p2Point2D

The end point of the gradient.

color_stopsArray.<ColorStop>

The color stops of the gradient.

Classes

LinearGradient

Members

color_stops

Gets the ColorStops of the gradient.

color_stops

Sets the ColorStops of the gradient.

p1

The start point of the gradient.

p1

The start point of the gradient.

p2

The end point of the gradient.

p2

The end point of the gradient.

Methods

color_at(p) → {Color}

Gets the Color at a given point along the gradient.

Parameters:
NameTypeDescription
pPoint2D

The point to get the color at.

Returns:

The color at the given point.

Type: 
Color

color_at_offset(position) → {Color}

Gets the Color at a given offset along the gradient.

Parameters:
NameTypeDescription
positionnumber

The offset to get the color at.

Returns:

The color at the given offset.

Type: 
Color

(static) default_linear_gradient() → {LinearGradient}

Returns the default LinearGradient, which is a gradient from the origin to the origin with no ColorStops.

Returns:

The default linear gradient.

Type: 
LinearGradient

(static) lerp(gradient1, gradient2, t) → {LinearGradient}

Linearly interpolates between two LinearGradients given a progress value.

Parameters:
NameTypeDescription
gradient1LinearGradient

The first linear gradient.

gradient2LinearGradient

The second linear gradient.

tnumber

The progress value.

Returns:

The interpolated linear gradient.

Type: 
LinearGradient

(static) single_color_gradient(p1, p2, color, repeatsopt) → {LinearGradient}

Returns the default LinearGradient, which is a gradient from the start to the end the same color.

Parameters:
NameTypeAttributesDescription
p1Point2D

The start point of the gradient.

p2Point2D

The end point of the gradient.

colorColor

The color of the gradient.

repeatsnumber | null<optional>

Number of times to repeat the color.

Returns:

The default linear gradient.

Type: 
LinearGradient