Metodo HTML canvas clearRect()
Esempio
Cancella un rettangolo all'interno di un determinato rettangolo:
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);
Supporto browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente il metodo.
Method | |||||
---|---|---|---|---|---|
clearRect() | Yes | 9.0 | Yes | Yes | Yes |
Definizione e utilizzo
Il metodo clearRect() cancella i pixel specificati all'interno di un determinato rettangolo.
sintassi JavaScript: | contesto .clearRect( x,y,larghezza,altezza ); |
---|
Valori dei parametri
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 |
❮ Riferimento tela HTML