Name

bounds( ) — get the bounding rectangle of a polygon

Synopsis

GD::Polygon::bounds

This method returns a list of values that describe the smallest rectangle that completely encloses the polygon. The return values are in a list of the form (left, top, right, bottom), where left is the x coordinate of the left side of the rectangle, topis the y value of the top, right is the x value of the right side, and bottom is the y value of the bottom. The following lines will draw a red box around a previously defined polygon:

my  @boundingBox = $poly->bounds;          # $poly is a polygon object
$image->rectangle(@boundingBox, red);

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.