Lets see how linear gradients are drawn on canvas using HTML5. In this tutorial, we take a rectangle and draw…