Metoda strokeRect() plátna HTML

❮ HTML Canvas Reference

Příklad

Nakreslete obdélník 150*100 pixelů:

Váš prohlížeč nepodporuje HTML5canvatag.

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() Yes 9.0 Yes Yes Yes

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

❮ HTML Canvas Reference