Metoda HTML canvas strokeRect ()
HTML Instrukcja płótno referencyjny
Przykłady
Narysuj prostokąt 150 * 100 pikseli:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.strokeRect(20,20,150,100);
var ctx=c.getContext("2d");
ctx.strokeRect(20,20,150,100);
Spróbuj »
Pomoc Browser
Internet Explorer 9, Firefox, Opera, Chrome i Safari wsparcie strokeRect metoda ().
Uwaga: 8 i wcześniejsze wersje programu Internet Explorer nie obsługuje <canvas> elementu.
Definicja i Wykorzystanie
Metoda strokeRect (), aby narysować prostokąt (bez wypełnienia). Domyślnym kolorem jest czarny uderzeń.
Wskazówka: Użyj strokeStyle nieruchomość ustawić skok kolor, gradient lub wzór.
Składnia JavaScript: | Kontekst .strokeRect (x, y, szerokość, wysokość); |
---|
parametr Wartość
参数 | 描述 |
---|---|
x | 矩形左上角的 x 坐标。 |
y | 矩形左上角的 y 坐标。 |
width | 矩形的宽度,以像素计。 |
height | 矩形的高度,以像素计。 |
HTML Instrukcja płótno referencyjny