Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (HTML Canvas) expand_more
HTML Canvas / Paths & Shapes

closePath

Learn closePath in HTML Canvas with a focused explanation, a topic-specific example, edge guidance, and a mastery check.

12 min read • Beginner
canvas-013.js
js
const canvas=document.querySelector("canvas");
const ctx=canvas.getContext("2d");
ctx.beginPath();ctx.moveTo(20,90);ctx.lineTo(90,20);ctx.lineTo(160,90);ctx.closePath();ctx.stroke();
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content