Metoda strokeRect() plátna HTML
Příklad
Nakreslete obdélník 150*100 pixelů:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.strokeRect(20, 20, 150, 100);
Podpora prohlížeče
Čísla v tabulce určují první verzi prohlížeče, která tuto metodu plně podporuje.
Method | |||||
---|---|---|---|---|---|
strokeRect() | 4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Definice a použití
Metoda strokeRect() nakreslí obdélník (bez výplně). Výchozí barva tahu je černá.
Tip: Pomocí vlastnosti strokeStyle nastavte barvu, přechod nebo vzor pro úpravu stylu tahu.
Syntaxe JavaScriptu: | kontext .strokeRect( x, y, šířka, výška ); |
---|
Hodnoty parametrů
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of the upper-left corner of the rectangle | |
y | The y-coordinate of the upper-left corner of the rectangle | |
width | The width of the rectangle, in pixels | |
height | The height of the rectangle, in pixels |
❮ Objekt plátna