Skip to main content
Version: 9.0.2

canvas.strokeRect

canvas.strokeRect(x1, y1, x2, y2, color)

Stroke a rectangle outline defined by the bounding area of x1,y2 to x2,y2 with a specific color. The width of the outline is the last value set to canvas.lineWidth or 1 if no width has ever been specified.

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
colornumberAn RGB color value as an integer value

Example

// Draw three colored outlines across the canvas
function strokeRGB(name) {
var canvas = sb.getCanvas(name);
var rw = canvas.width / 3;
canvas.strokeRect(0, 0, rw-1, canvas.height, 0xff0000);
canvas.strokeRect(rw, 0, 2*rw-1, canvas.height, 0x00ff00);
canvas.strokeRect(2*rw, 0, 3*rw-1, canvas.height, 0x0000ff);
}