Metoda HTML canvas fillRect().

❮ HTML Canvas Reference

Příklad

Nakreslete vyplněný obdélník 150*100 pixelů:

Váš prohlížeč nepodporuje HTML5canvatag.

JavaScript:

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillRect(20, 20, 150, 100);

Podpora prohlížeče

Čísla v tabulce určují první verzi prohlížeče, která tuto metodu plně podporuje.

Method
fillRect() Yes 9.0 Yes Yes Yes

Definice a použití

Metoda fillRect() nakreslí „vyplněný“ obdélník. Výchozí barva výplně je černá.

Tip: Pomocí vlastnosti fillStyle nastavte barvu, přechod nebo vzor použitý k vyplnění výkresu.

Syntaxe JavaScriptu: kontext .fillRect( 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