Image & Canvas
canvasDrawRect
$canvasDrawRect
Draws a rectangle (filled or outline only) with optional blend mode
Syntax
$canvasDrawRect[x;y;width;height;color;fill;blend?;container?]
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| x | integer | check_circle Required | — | Top-left X coordinate |
| y | integer | check_circle Required | — | Top-left Y coordinate |
| width | integer | check_circle Required | — | Rectangle width in pixels |
| height | integer | check_circle Required | — | Rectangle height in pixels |
| color | color | check_circle Required | — | Fill or outline color |
| fill | boolean | check_circle Required | — | true = filled, false = outline only (1px border) |
| blend | string | Optional | — |
Blend mode
multiply
screen
overlay
darken
lighten
difference
hardLight
softLight
|
| container | string | Optional | — | Container name for relative positioning |
Return Value
canvas
Modifies the canvas in-place.
When fill is false, the rectangle is drawn as a 1-pixel wide outline — there is no thickness parameter. For thicker outlines, use multiple overlapping rectangles or $canvasDrawLine calls. For rectangles with rounded corners, prefer $canvasDrawRoundedRect. The blend mode enables per-pixel compositing for effects like shadows and overlays.
Examples
Filled rectangle
$canvasCreate[box;300;200;white]
$canvasDrawRect[50;50;200;100;E53935;true]
$attachImage[box]
Outline rectangle
$canvasDrawRect[50;50;200;100;000000;false]