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.