Skip to content

Rectangle

Rectangle is a drawable item in the Imagick Layout Engine that renders a rectangle onto an Imagick canvas. It supports margin, padding, and border

$drawBackground = draw(fill: 'red');
$drawBorder = draw(stroke: 'black', strokeWidth: 10);
$rectangle = new Rectangle($drawBackground);
// Optional spacing and border
$rectangle->setMargin(10);
$rectangle->setPadding(8);
$rectangle->setBorder($drawBorder);
// Draw rectangle onto image
$rectangle->draw($imagick, $x, $y, $width, $height);

A red rectangle with margin, padding, and a black border

The same rectangle as a template:

{
"type": "rectangle",
"fill": "red",
"margin": 10,
"padding": 8,
"border": { "stroke": "black", "strokeWidth": 10 }
}

llms.txt