Advertisement
Home Open Editor ❯

HTML canvas closePath() Method

Example

let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");

ctx.beginPath();
ctx.moveTo(25, 25);
ctx.lineTo(25, 100);
ctx.lineTo(100, 100);
ctx.closePath();
ctx.stroke();

Try this code ❯

Meaning

The closePath() method creates a path from the current point back to the starting point.


Standard Syntax

JavaScript syntax:

context.closePath(x,y);


Advertisement

Home Open Editor ❯
Advertisement