Mega Code Archive

 
Categories / Php / Graphics
 

Drawing a Triangler

<?php      header ("Content-type: image/png");          $im = ImageCreate (175, 175);          $grey = ImageColorAllocate ($im, 230, 230, 230);      $black = ImageColorAllocate ($im, 0, 0, 0);          $coordinates = array();          $coordinates[0] = 0;            // Point 1 x      $coordinates[1] = 150;          // Point 1 y      $coordinates[2] = 150;          // Point 2 x      $coordinates[3] = 150;          // Point 2 y      $coordinates[4] = 75;           // Point 3 x      $coordinates[5] = 75;           // Point 3 y          ImageFilledPolygon($im, $coordinates, 3, $black);          ImageString($im, 3, 5, 5, "Figure 18.4: Triangle", $black);      ImagePng ($im);      ImageDestroy ($im); ?>