Lets see how linear gradients are drawn on canvas using HTML5. In this tutorial, we take a rectangle and draw linear gradient color as its fill color(fillStyle). HTML file index.html. I would like to fill a shape on a html5 canvas with a gradient created from several differents colors at different positions, like on this picture. Do you have any ideas on how I could do that? Canvas Color Gradient. A Pen By redmed. Run.HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug. Nearly every operation in HTML5s canvas function implements a fill or stroke style. To get the most out of canvas, you need to understand how they work. The three primary types of styles you can use on fills and strokes are colors, gradients, and patterns. Search Guides and Sample Code. Safari HTML5 Canvas Guide.Gradients. A gradient specifies a starting color, an ending color, and an area over which color changes.