JavaScript: The Definitive Guide

25.19. CanvasRenderingContext2D.createLinearGradient( ): create a linear color gradient

25.19.1. Synopsis

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

25.19.1.1. Arguments

xStart, yStart

The coordinates of the gradient's start point.

xEnd, yEnd

The coordinates of the gradient's end point.

25.19.1.2. Returns

A CanvasGradient object representing a linear color gradient.

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

25.19.3. See Also

CanvasGradient.addColorStop( ), CanvasRenderingContext2D.createRadialGradient( )

Категории