Circles

GD example

Circles example
<?php // Create the canvas
$image imagecreate(400,400);

// Background colour
$white ImageColorAllocate($image,255,255,255);

// The colours for the circles
$blue ImageColorAllocate($image,0191255 );
$orange ImageColorAllocate($image,255165);
$red ImageColorAllocate($image,255,0,0);
$pink ImageColorAllocate($image,25520147);
$green ImageColorAllocate($image,127255);
$purple ImageColorAllocate($image,1480211 );
$yellow ImageColorAllocate($image,238221130);
$cyan ImageColorAllocate($image,0255255);
$dark_green ImageColorAllocate($image,01000  );
$maroon ImageColorAllocate($image,2059292 );
$peach ImageColorAllocate($image,255218185);

// The array to sellect the colours from
$color = array( $blue$red$orange$pink$green$purple$yellow$cyan$dark_green$maroon$peach );
$random_colour array_rand($color,7);

// Creat a bounding rectangle
ImageFilledRectangle($image,0,0,200,200,$white);

// Create the random size circles with random colours but contain them in the bounding box
$x rand(45255);
$y rand(45255);
$r rand(2090);
imagefilledellipse($image$x$y$r,$r$random_colour[0]);
$x rand(20280);
$y rand(20280);
$r rand(2040);
imagefilledellipse($image$x$y$r,$r$random_colour[1]);
$x rand(35265);
$y rand(35265);
$r rand(2070);
imagefilledellipse($image$x$y$r,$r$random_colour[2]);
$x rand(15285);
$y rand(15285);
$r rand(2030);
imagefilledellipse($image$x$y$r,$r$random_colour[3]);
$x rand(45255);
$y rand(45255);
$r rand(2090);
imagefilledellipse($image$x$y$r,$r$random_colour[4]);
$x rand(20280);
$y rand(20280);
$r rand(2040);
imagefilledellipse($image$x$y$r,$r$random_colour[5]);
$x rand(35265);
$y rand(35265);
$r rand(2070);
imagefilledellipse($image$x$y$r,$r$random_colour[6]);
$x rand(15285);
$y rand(15285);
$r rand(2030);
imagefilledellipse($image$x$y$r,$r$random_colour[7]);

// Change the background colour to transparent
ImageColorTransparent($image,$white);

// Save the result as circles.png
imagePNG($image,'circles.png');
imagedestroy($image); ?>

This is created using GD rather than ImageMagick; it was some code I was trying out to see what the effect would be. It could be improved on with more randoms for the colour selection etc. For some reason I get some white circles as well and I do not know where they are comming from !