Metoda HTML canvas clearRect().
Příklad
Vymazat obdélník v daném obdélníku:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 300, 150);
ctx.clearRect(20, 20, 100, 50);
Podpora prohlížeče
Čísla v tabulce určují první verzi prohlížeče, která tuto metodu plně podporuje.
Method | |||||
---|---|---|---|---|---|
clearRect() | 4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Definice a použití
Metoda clearRect() vymaže zadané obrazové body v daném obdélníku.
Syntaxe JavaScriptu: | kontext .clearRect( x, y, šířka, výška ); |
---|
Hodnoty parametrů
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of the upper-left corner of the rectangle to clear | |
y | The y-coordinate of the upper-left corner of the rectangle to clear | |
width | The width of the rectangle to clear, in pixels | |
height | The height of the rectangle to clear, in pixels |
❮ Objekt plátna