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(
)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access