Name
CanvasGradient — a color gradient for use in a canvas
Methods
addColorStop()
Specifies a color and position for the gradient
Description
A CanvasGradient object represents a color gradient that may be
assigned to both the strokeStyle
and
fillStyle
properties of a CanvasRenderingContext2D
object. The createLinearGradient()
and
createRadialGradient()
methods of
CanvasRenderingContext2D both return CanvasGradient objects.
Once you have created a CanvasGradient object, use
addColorStop()
to specify what colors should appear
at what positions within the gradient. Between the positions you
specify, colors are interpolated to create a smooth gradient or fade. If
you specify no color stops, the gradient will be uniform transparent
black.
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.