Code
Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy HTML Canvas closePath Method</title> </head> <body> <h1>Wikitechy HTML Canvas closePath Method</h1> <canvas id="wikitechyCanvas" width="200" height="150" style="border:2px solid red;"> </canvas> <script> var cp= document.getElementById("wikitechyCanvas"); var cpx = cp.getContext("2d"); cpx.beginPath(); cpx.moveTo(30, 10); cpx.lineTo(150, 75); cpx.lineTo(15, 100); cpx.closePath(); cpx.stroke(); </script> </body> </html>
Result