August 15, 2022

WeAnswer

The complete guide to the beginners as well as to the experienced Web Developers

Draw a line using HTML5 Canvas, we can use the beginPath(), moveTo(), lineTo(), and stroke() method.

Result

Property

context.lineWidth = 15;

context.strokeStyle = ‘#ff0000’;
context.stroke();

context.lineWidth = 20;
context.strokeStyle = ‘#0000ff’;
context.lineCap = ’round’;
context.stroke();