Name
CanvasRenderingContext2D.createLinearGradient( ): create a linear color gradient
Synopsis
CanvasGradient createLinearGradient(floatxStart
, floatyStart
, floatxEnd
, floatyEnd
)
Arguments
-
xStart, yStart
The coordinates of the gradientâs start point.
-
xEnd, yEnd
The coordinates of the gradientâs end point.
Returns
A CanvasGradient object representing a linear color gradient.
Description
This method creates and returns a new CanvasGradient object
that linearly interpolates colors between the specified start point
and end point. Note that this method does not specify any colors for
the gradient. Use the addColorStop(
)
method of the returned object to do that. To stroke
lines or fill areas using a gradient, assign a CanvasGradient object
to the strokeStyle
or fillStyle
properties.
See Also
CanvasGradient.addColorStop(
)
, CanvasRenderingContext2D.createRadialGradient(
)
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.