canvas.fillRect
canvas.fillRect(x1, y1, x2, y2, color)
Fill a rectangle defined by the bounding area of x1,y2 to x2,y2 with a specific color.
Parameters
| Parameter | Type | Description |
|---|---|---|
x1 | number | The x position of the first corner. |
y1 | number | The y position of the first corner. |
x2 | number | The x position of the second corner. |
y2 | number | The y position of the second corner. |
color | number | An RGB color value as an integer value. |
Example
//Draw three colored bars across the canvas
function fillRGB(name) {
var canvas = sb.getCanvas(name);
var rw = canvas.width / 3;
canvas.fillRect(0, 0, rw, canvas.height, 0xff0000);
canvas.fillRect(rw, 0, 2*rw, canvas.height, 0x00ff00);
canvas.fillRect(2*rw, 0, 3*rw, canvas.height, 0x0000ff);
}