HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
HTML Canvas Reference : Draw a path, shaped as the letter L, and then draw a line back to the starting point
The numbers in the table specify the first browser version that fully supports the method.
Method | |||||
---|---|---|---|---|---|
closePath() | Yes | 9.0 | Yes | Yes | Yes |
The closePath() method creates a path from the current point back to the starting point.
JavaScript syntax: | context.closePath(); |
---|
Use red as the fill color:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20, 20);
ctx.lineTo(20, 100);
ctx.lineTo(70, 100);
ctx.closePath();
ctx.stroke();
ctx.fillStyle = "red";
ctx.fill();
❮ HTML Canvas Reference