Name

vertices( ) — get all the vertices in a polygon

Synopsis

GD::Polygon::vertices()

This method returns all the vertices as a list. Thus, for a list of returned vertices called @vertices, $vertices[0][0] refers to the x value of the first point, and $vertices[1][1] refers to the y value of the second point. You may want to convert this list into a portable string of x, y pairs separated by white space as in the addPt( ) example:

# Save a list of vertices as a string
#
my (@vertices, $polyPoints);

# Get the list of vertices as a two dimensional array
#
@vertices = $polywolly->vertices();

# Iterate over each coordinate pair
#
foreach (@vertices) {
    # Delimit each x, y pair with a comma and each point with a single space
    #
    $polyPoints .= join(join ",", @$_)." ";
}

print "Here's all the points in polywolly: $polyPoints\n";       
                     
                     

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.