/

HTML / CSS / JavaScript Tutorial

JavaScript canvas2d object method: createRadialGradient()

[this page | pdf | back links]

The createRadialGradient() method of the JavaScript DOM object returned by the getContext("2d") method applied to the HTML <canvas> element creates a radial (i.e. circular) gradient. The resulting object can be used as the value of the strokeStyle or fillStyle properties and hence to fill in rectangles, circles etc. You need to apply some addColorStop() methods to the gradient for it to be visible.

 

It has the following syntax with the following parameters.

 

context.createRadialGradient(xstart, ystart, rstart, xend, yend, rend)

 

Parameter

Required / Optional

Description

xstart

Required

x-coordinate of centre of starting circle of gradient

xend

Required

y-coordinate of centre of starting circle of gradient

rstart

Required

Radius of starting circle

ystart

Required

x-coordinate of centre of ending circle of gradient

yend

Required

y-coordinate of centre of ending circle of gradient

rend

Required

Radius of ending circle

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile