HTML canvas stroke () method
Examples
Draw a path shape is a red letter L:
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();
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
Internet Explorer 9, Firefox, Opera, Chrome and Safari support stroke () method.
Note: 8 and earlier versions of Internet Explorer do not support the <canvas> element.
Definition and Usage
stroke () method will actually draw the path defined by the method moveTo () and lineTo () of. The default color is black.
Tip: Use strokeStyle property to draw another color / gradient.
JavaScript syntax: | context .stroke ( ); |
---|
HTML canvas Reference Manual