JavaScripture
Contribute via GitHub Feedback

JavaScript CanvasGradient : Object

Defines a linear or radial gradient that can be used as the fillStyle or strokeStyle of a CanvasRenderingContext2D. Created through createLinearGradient() or createRadialGradient().

Instance Methods

addColorStop(offset : Number, color : String) : undefined

Adds a color stop in the gradient. offset must be between 0 and 1, where 0 is the start of the gradient and 1 is the end of the gradient. color is a string representation of the color such as 'black', '#000', 'rgba(0, 0, 0, 1)', etc.

Example:

Run

Results: