Skip to main content
Version: 9.0.2

canvas.clearRect

cavas.clearRect(x1, y1, x2, y2)

Make transparent a rectangle defined by the bounding area of x1,y2 to x2,y2.

Parameters

ParameterTypeDescription
x1numberThe x position of the first corner.
y1numberThe y position of the first corner.
x2numberThe x position of the second corner.
y2numberThe 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);
}