A polygon is a multi-sided shape. Minimum number of sides is three. In theory there is no maximum.


An array is a series of instructions to the browser in a package. In this case the array designates the points of our polygon. Each point will have an x and a y designated. The array is packaged in parenthesis. After the array is a number that designates how many total points are in your figure. In this case 3. That is followed by a color . A polygon may be just lines or filled.

Note the following example:
//imagePolygon ($im, array ( 0, 30, 10, 0, 10, 60 ), 3, $gold);

These are the same shapes as in lessons one and two. We just add polygon.

Can you make a polygon of five sides...?
Can you put a smaller, filled three sided polygon inside...?
Rearrange the shapes to layer them differently.
See if you can make a cat with two triangle ears a circle head and a circle body.

GD BasicsHome