YouTip LogoYouTip

Met Canvas Stroke

# HTML canvas stroke() Method [![Image 8: Canvas Object Reference Manual](#) Canvas Object](#) ## Example Draw a path in the shape of the letter L in red: YourbrowserdoesnotsupporttheHTML5canvastag. 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.strokeStyle="red"; ctx.stroke(); [Try it »](#) * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the stroke() method. **Note:** Internet Explorer 8 and earlier versions do not support the element. * * * ## Definition and Usage The stroke() method actually draws the path defined by the moveTo() and lineTo() methods. The default color is black. **Tip:** Use the (#) property to draw in another color/gradient. | JavaScript Syntax: | _context_.stroke(); | | --- | * * Canvas Object](#)
← Met Canvas BeginpathMet Canvas Fill β†’