canvas.clearRect
cavas.clearRect(x1, y1, x2, y2)
Make transparent a rectangle defined by the bounding area of x1,y2 to x2,y2.
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. |
Example
// Fill a canvas with red and poke a transparent hole in the middle of it
function makeTransparentHole(name) {
var canvas = sb.getCanvas(name);
var holeWidth = canvas.width / 3;
var holeHeight = canvas.height / 3;
canvas.fill(0xff0000);
canvas.clearRect(holeWidth, holeHeight, 2*holeWidth, 2*holeHeight);
}