HTML canvas stroke() method
Definition and usage
stroke()
Methods actually draw the path defined by moveTo() and lineTo() Method defines the path. The default color is black.
Tip:Please use strokeStyle Property to draw another color/gradient.
Example
Draw a path, the shape is a green 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="green"; ctx.stroke();
Syntaksi
context.stroke();
Selaimen tuki
Taulukossa olevat numerot osoittavat ensimmäisen täysin tukevan selaimen version.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Huomautus:Internet Explorer 8 ja aikaisemmat versiot eivät tue <canvas> -elementtiä.