Name

CRC.createLinearGradient() — create a linear color gradient

Synopsis

CanvasGradient createLinearGradient(float xStart,
                                    float yStart,
                                    float xEnd, 
                                    float yEnd)

Arguments

xStart, yStart

The coordinates of the gradient’s start point

xEnd, yEnd

The coordinates of the gradient’s endpoint

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 endpoint. 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.

Get Canvas Pocket Reference 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.