\n"; print "
\n"; print "Enter a formula:
\n"; print "
\n"; print "The graph of $formula from 0 to $WIDTH
\n"; # print the imagemap print "\n"; print " \"Polygon\"\n"; print ""; } else # draw the picture { header("Content-Type: image/png"); $image = ImageCreate($WIDTH, $HEIGHT); # Make an image $yellow = ImageColorAllocate($image, 255,255,0); # Allocate a color $red = ImageColorAllocate($image, 255,0,0); # Draw the background in yellow ImageFilledRectangle($image, 0,0,$SIZEX, $SIZEY, $yellow); $polygon = points($formula, 0, $WIDTH); #print_r($polygon); ImageFilledPolygon($image, $polygon, ($WIDTH + 1), $red); ImagePNG($image); } function points($formula, $minx, $maxx) { # Make a polygon with the formula $polygon[] = $maxx; # upper right corner $polygon[] = 0; $polygon[] = 0; # upper left corner $polygon[] = 0; for($x = $minx; $x < $maxx; $x++) { #print "\$x = $x; return $formula;
\n"; $y = round(eval("\$x = $x; return $formula;")); $polygon[]=$x; $polygon[]=$y; } return $polygon; } ?>