PHP program to draw different shapes.

CODE:

<?php
  header('Content-type: image/png');
  $png_image = imagecreate(400, 400);
  $grey = imagecolorallocate($png_image, 199, 199, 199);
  $green = imagecolorallocate($png_image, 0, 255,0);
  $red   = imagecolorallocate($png_image, 255, 0, 0);
  $blue  = imagecolorallocate($png_image, 0, 0, 255);
  $black = imagecolorallocate($png_image, 0, 0, 0);
  $orange = imagecolorallocate($png_image, 255, 200, 0);
  imagefilltoborder($png_image, 0, 0, $grey, $grey);

   imagefilledrectangle ($png_image, 20, 20, 80, 80, $red);
   imagefilledrectangle ($png_image, 100, 20, 280, 80, $blue);   // RECTANGLE
  imagefilledellipse ($png_image, 50, 150, 75, 75, $green);      // CIRCLE
  imagefilledellipse ($png_image, 200, 150, 150, 75, $black);    // ELLIPSE

    $poly_points = array(150, 200, 100, 280, 200, 280);
  imagefilledpolygon ($png_image, $poly_points, 3, $orange); 

  imagepng($png_image);
  imagedestroy($png_image);
?>

OUTPUT:


Comments

POPULAR POSTS

POPULAR POSTS