Veronica's code for a Unique Drawing
SLAVE CODE FOLLOWS
<?php
// create unique image
// create a blank image that is 200 pixels wide and 200 pixels tall
$image = imagecreate(350, 350);
// background color (RGB HEX)
$gray = imagecolorallocate($image, 0xEF, 0xEF, 0xEF);
// colors for shape (all RGB HEX)
$lightblue = imagecolorallocate ($image, 0x24, 0xC8, 0xF0);
$blue = imagecolorallocate ($image, 0x0, 0x0, 0xFF);
$bluepurple = imagecolorallocate ($image, 0xA8, 0x2B, 0xE2);
$purple = imagecolorallocate ($image, 0x77, 0x0F, 0xA2);
$redpurple = imagecolorallocate ($image, 0x99, 0x01, 0x47);
$red = imagecolorallocate($image, 0xFF, 0x00, 0x00);
$redorange = imagecolorallocate($image, 0xFF, 0x53, 0x49);
$orange = imagecolorallocate($image, 0xFF, 0xA5, 0x00);
$yelloworange = imagecolorallocate($image, 0xFC, 0xCF, 0x8B);
$yellow = imagecolorallocate($image, 0xFF, 0xFF, 0xAA);
$yellowgreen = imagecolorallocate($image, 0x80, 0xFF, 0x00);
$green = imagecolorallocate($image, 0x80, 0xC0, 0x00);
$greenblue = imagecolorallocate($image, 0x0D, 0xBA, 0xB1);
$bluegreen = imagecolorallocate($image, 0x0D, 0xB5, 0xBA);
$darkbluegreen = imagecolorallocate($image, 0x08, 0x5E, 0x72);
$pink = imagecolorallocate($image, 0xEB, 0x30, 0xEB);
// variables for rotated text
$font = 'fonts/arial.ttf';
$str = " My Shapes ( :";
// rotated text
imagettftext($image, 24, 45, 15, 160, $blue, $font, $str);
// variables for shape
$center = 130;
$center_y = 100;
$width = 100;
$height = 25;
$start_angle = 0;
$end_angle = 360;
// iteration variables
$j = 0;
//$change_j = 4;
$change_i = 61;
// Draw ovals (image, x, y, arc-width, arc-height, start-angle, end-angle, color)
for ($i = 0; $i < $change_i; $i += 4)
{
switch ($i) {
case ($i >= 60):
$color = $lightblue;
break;
case ($i >= 56):
$color = $blue;
$j = $j + 1;
break;
case ($i >= 52):
$color = $bluepurple;
break;
case ($i >= 48):
$color = $purple;
break;
case ($i >= 42):
$color = $redpurple;
break;
case ($i >= 38):
$color = $red;
break;
case ($i >= 32):
$color = $redorange;
break;
case ($i >= 28):
$color = $orange;
$j = $j + 1;
break;
case ($i >= 24):
$color = $yelloworange;
break;
case ($i >= 20):
$color = $yellow;
break;
case ($i >= 16):
$color = $yellowgreen;
break;
case ($i >= 12):
$color = $green;
$j = $j + 1;
break;
case ($i >= 8):
$color = $greenblue;
break;
case ($i >= 4):
$color = $bluegreen;
break;
default:
$color = $darkbluegreen;
break;
}
// draw
imagearc($image, $center, $center_y, $width, $height, $start_angle, $end_angle, $color);
// adjust placement
if($j = 0)
{
$center -= 4;
$center_y += 3;
}
elseif($j = 1)
{
$center += 4;
$center_y += 3;
}
elseif($j = 2)
{
$center += 4;
$center_y -= 3;
}
else
{
$center -= 4;
$center_y -= 3;
}
}
// === create a polygon
// populate the polygon (a triangle) with paired x-y coordinates
$triangle = array(60,120, 140,270, 300,270 );
// number of coordinates (pairs) in the $triangle
$pts = count($triangle)/2;
// draw the polygon on the image using current color
imagepolygon($image, $triangle, $pts, $blue);
// draw a filled polygon on the image using current color
imagefilledpolygon($image, $triangle, $pts, $greenblue);
// === create another graphic
// new variables
$center = 50;
$PI = 2 * pi();
$a = 1;
$b = 1;
$m = 8;
$n1 = 5;
$n2 = 6;
$n3 = 24;
// create graphic
for($f = 0; $f <= $PI; $f += 0.0001)
{
$r= pow((pow(abs(cos($m*$f/4)/$a),$n2) + pow(abs(sin($m*$f/4)/$b), $n3)), -(1/$n1));
$x = $center + $r * cos ($f) * 25;
$y = $center + $r * sin ($f) * 25 + 180;
imagesetpixel($image, $x, $y, $pink);
}
// === create another graphic, polygon
// initial variables
$x = 320;
$y = 200;
$corners[0] = array('x' => 310, 'y' => 10);
$corners[1] = array('x' => 200, 'y' => 300);
$corners[2] = array('x' => 320, 'y' => 340);
// create the graphic
for ($i = 0; $i < 1000000; $i++)
{
if($y > 290)
{
imagesetpixel($image, round($x), round($y), $red);
}
elseif($y > 190)
{
imagesetpixel($image, round($x), round($y), $redorange);
}
elseif($y > 90)
{
imagesetpixel($image, round($x), round($y), $orange);
}
elseif($y > 0)
{
imagesetpixel($image, round($x), round($y), $yelloworange);
}
else
{
imagesetpixel($image, round($x), round($y), $yellow);
}
$a = rand(0, 2);
$x = ($x + $corners[$a]['x']) / 2;
$y = ($y + $corners[$a]['y']) / 2;
}
//=== display the image
// tell the server that a PNG image follows
header("Content-type: image/png");
// display the image
imagepng($image);
// destroy the image (i.e., release memory)
imagedestroy ($image);
?>