rectangle — draw a rectangle
Description
public Intervention\Image\Image rectangle(string $color, integer $x1, integer $y1, integer $x2 = 10, integer $y2, [boolean $filled])
Draw a colored rectangle on current image with top-left corner on x,y point 1 and bottom-right corner at x,y point 2. By default the rectangle will be filled completely, if you want just draw a border pass boolean false as an optional last parameter.
Parameters
color
The color of the rectangle. Pass a color in one of the different color formats.
x1
X-Coordinate of the top-left point of the rectangle.
y1
Y-Coordinate of the top-left point of the rectangle.
x2
X-Coordinate of the bottom-right point of the rectangle.
y2
Y-Coordinate of the bottom-right point of the rectangle.
filled (optional)
Whether to fill the rectangle or not. Default: true
Return Values
Instance of Intervention\Image\Image
Examples
// create empty canvas with background color
$img = Image::canvas(100, 100, '#ddd');
// draw filled blue rectangle
$img->rectangle('#0000ff', 10, 10, 190, 190);
// draw non-filled red rectangle
$img->rectangle('#ff0000', 5, 5, 195, 195, false);
// draw transparent rectangle
$img->rectangle('rgba(255, 255, 255, 0.5)', 5, 5, 195, 195, false);