Canvas Properties for Drawing Lines

Syntax

canvas2.lineWidth = 10;
canvas1.strokeStyle = "blue";
canvas2.lineCap = "round";

Properties

  • lineWidth: In this property, we define the thickness or width of the line.
  • strokeStyle: In this property, we define the style of the line.
  • lineCap: In this property, we define the cap style that is applied on the top and bottom (start and end) of the line. There are three styles can be used butt, round, and square.

HTML Canvas Lines

In this article, we will learn how to make lines in different styles on Canvas in HTML. There are various methods used to draw a line on canvas like beginPath(), moveTo(), lineTo(), and stroke(). There are also various properties like lineWidth, strokeStyle, etc. can be used to give styles to a line with the help of JavaScript.

Similar Reads

Syntax

canvas1.lineTo(100, 150);...

Canvas Methods for Drawing Lines

Syntax...

Canvas Properties for Drawing Lines

Syntax...

Using the lineTo() method and lineWidth property

The HTML Canvas ‘lineTo’ method delicately connects points, while the ‘lineWidth’ property subtly refines the strokes, resulting in a seamless fusion of precision and style on the digital canvas....

Using the lineTo() method and lineCap property

...