Linear Gradient in Canvas in HTML
As we know, a gradient is a smooth transition from one color to another. We can apply it to different shapes, and boxes on canvas.
The method used for the linear gradient is:-
- x is the initial x-coordinate.
- y is the initial y-coordinate.
- x1 is the final x-coordinate.
- y1 is the final y-coordinate.
For your Information:-
The addColorStop() method defines the color stops and their position along the gradient. Gradient positions can be anywhere between 0 to 1.