HTML canvas strokeRect() method
Definition and usage
strokeRect()
Method to draw a rectangle (no fill). The default color of the stroke is black.
Tip:Please use strokeStyle Properties to set the color, gradient, or pattern of the stroke.
Example
Draw a 150*100 pixel rectangle:
JavaScript:
var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.strokeRect(20,20,150,100);
Syntaksi
context.strokeRect(x,y,width,height);
Parametrien arvot
Parametrit | Kuvaus |
---|---|
x | Suorakulmion ylävasemman x-koordinaatti. |
y | Suorakulmion ylävasemman y-koordinaatti. |
width | Suorakulmion leveys, pisteinä. |
height | Suorakulmion korkeus, pisteinä. |
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ä.