Metoda HTML canvas clearRect().

❮ HTML Canvas Reference

Příklad

Vymazat obdélník v daném obdélníku:

Váš prohlížeč nepodporuje HTML5canvatag.

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

Definice a použití

Metoda clearRect() vymaže zadané obrazové body v daném obdélníku.

Syntaxe JavaScriptu: kontext .clearRect( x,y,width,height );

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

❮ HTML Canvas Reference