YouTip LogoYouTip

Met Canvas Beginpath

# HTML canvas beginPath() Method [![Image 8: Canvas Object Reference Manual](#) Canvas Object](#) ## Example Draw two paths on the canvas; green and purple: YourbrowserdoesnotsupporttheHTML5canvastag. JavaScript: var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.beginPath(); ctx.lineWidth="5"; ctx.strokeStyle="green"; // Green path ctx.moveTo(0,75); ctx.lineTo(250,75); ctx.stroke(); // Draw it ctx.beginPath(); ctx.strokeStyle="purple"; // Purple path ctx.moveTo(50,0); ctx.lineTo(150,130); ctx.stroke(); // Draw it [Try it »](#) * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The beginPath() method is supported in Internet Explorer 9, Firefox, Opera, Chrome, and Safari. **Note:** Internet Explorer 8 and earlier versions do not support the element. * * * ## Definition and Usage The beginPath() method begins a path, or resets the current path. **Tip:** Use the methods moveTo(), lineTo(), quadricCurveTo(), bezierCurveTo(), arcTo(), and arc() to create paths. **Tip:** Use the [stroke()](#) method to actually draw the path on the canvas. | JavaScript syntax: | _context_.beginPath(); | | --- | * * Canvas Object](#)
← Met Canvas MovetoMet Canvas Stroke β†’