Metodo HTML canvas fillRect()
Esempio
Disegna un rettangolo pieno di 150*100 pixel:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillRect(20, 20, 150, 100);
Supporto del browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente il metodo.
Method | |||||
---|---|---|---|---|---|
fillRect() | Yes | 9.0 | Yes | Yes | Yes |
Definizione e utilizzo
Il metodo fillRect() disegna un rettangolo "riempito". Il colore predefinito del riempimento è il nero.
Suggerimento: utilizza la proprietà fillStyle per impostare un colore, una sfumatura o un motivo utilizzato per riempire il disegno.
sintassi JavaScript: | contesto .fillRect( x,y,larghezza,altezza ); |
---|
Valori dei parametri
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 |
❮ Riferimento tela HTML