srinivas6203 Posted January 2, 2008 Share Posted January 2, 2008 There is any function to obtain the coordinates of a polygon Quote Link to comment https://forums.phpfreaks.com/topic/84070-coordinates-of-polygon/ Share on other sites More sharing options...
Barand Posted January 2, 2008 Share Posted January 2, 2008 This gives a regular hexagon. $rad is the radius Set $step to 360 / (number of sides) for others <?php header("Content-type: image/png"); $im = imagecreate(200, 200); $green = imagecolorallocate($im, 0, 255, 0); $red = imagecolorallocate($im, 255, 0, 0); $step = 60; $rad = 80; $centrex = imagesx($im)/2; $centrey = imagesy($im)/2; for ($i=0; $i<360; $i+=$step) { $points[] = $centrex + $rad*cos(deg2rad($i)); $points[] = $centrey + $rad*sin(deg2rad($i)); } $vertices = count($points) / 2; imagepolygon($im, $points, $vertices, $red); imagepng($im); imagedestroy($im); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84070-coordinates-of-polygon/#findComment-427966 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.