HTML-doek clearRect() Metode
Voorbeeld
Maak 'n reghoek binne 'n gegewe reghoek skoon:
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);
Blaaierondersteuning
Die nommers in die tabel spesifiseer die eerste blaaierweergawe wat die metode ten volle ondersteun.
Method | |||||
---|---|---|---|---|---|
clearRect() | Yes | 9.0 | Yes | Yes | Yes |
Definisie en gebruik
Die clearRect() metode maak die gespesifiseerde pixels binne 'n gegewe reghoek skoon.
JavaScript-sintaksis: | konteks .clearRect( x,y, breedte, hoogte ); |
---|
Parameterwaardes
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-doekverwysing