//WIDTH AND HEIGHT OF BACKGROUND
$width = 300;
$height = 300;
$im = imagecreate($width,$height);
//BACKGROUND COLOR--SET TO BLACK
$background_color = imagecolorallocate($im, 0, 0, 0);
//MAKE BG TRANSPARENT--REMOVE THIS LINE
//FOR A COLORED BACK
imagecolortransparent( $im, $background_color );
//SOME COLORS I MIGHT USE ON THIS PAGE
$white = imagecolorallocate($im,255,255,255);
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$yellow = imagecolorallocate($im, 255, 255, 0);
//DRAW 2 CIRCLES AND FILL THE CENTER BETWEEN THEM
//SAME AS IM-CENTER POINT AND OUTER SIZE
imageellipse($im, 150, 150, 285, 285, $red);
imageellipse($im, 150, 150, 295, 295, $red);
//SAME AS PAINT AT IM--CLICK THIS POINT AND FLOODFILL
imagefill($im, 4, 150, $red);
//DRAW THE DIAMOND SHAPE IN CENTER
//LINES ARE X,Y TO X,Y AND COLOR
//X=PIXELS FROM LEFT, Y=PIXELS FROM TOP
imageline($im, 130, 150, 150, 130, $green);
imageline($im, 150, 130, 170, 150, $green);
imageline($im, 150, 170, 170, 150, $green);
imageline($im, 130, 150, 150, 170, $green);
//PAINT IT GREEN
imagefill($im, 150, 150, $green);
//BEGIN LOOP COMMANDS--X1 IS -25, 25 OFF THE PAGE
//TELLS IT TO TAKE X1 AND ADD 25 TO IT (NOW ITS 0)
//DRAW A LINE, KEEP DRAWING LINES X1+25 UNTIL X1=300
$x1 = -25;
while ($x1 < 300) {
$x1 = $x1 + 25;
$x2 = -25;
while ($x2 < 300) {
$x2 = $x2 + 25;
$y1 = -25;
while ($y1 < 300) {
$y1 = $y1 +25;
$y2 = -25;
while ($y2 < 300) {
$y2 = $y2 + 25;
//THERE WERE 4 LOOPS OPENED FOR 4 DIFFERENT
//XY POINTS. THE LOOPS OPEN WITH A CURLY BRACKET
//BEGIN DRAWING LINES AT POINT X,Y TO X,Y
//1ST LINE GO IN 150 AND DRAW LINES THAT
//CONVERGE ON TO POINT 299, 150 (300 WAS OFF THE PAGE
imageline($im, 150, $x1, 299, 150, $yellow);
//GO DOWN 150 DRAW LINES TO CONVERGE ON 150,299
imageline($im, $x2, 150, 150, 299, $yellow);
//GO IN 150 DRAW LINES TO CONVERGE ON 1,150
imageline($im, 150, $y1, 1, 150, $yellow);
//GO DOWN 150 DRAW LINES TO CONVERGE ON 150,1
imageline($im, $y2, 150, 150, 1, $yellow);
//CLOSE THE FOUR LOOP COMMANDS WITH 4 BRACKETS
}
}
}
}
//DRAW A FAT LINE OR SKINNY RECTANGLE FROM TOP
//TO BOTTOM XY, XY FILLED WITH COLOR ALREADY
imagefilledrectangle($im, 148, 0, 152, 300, $green);
//ANOTHER ACROSS THE PAGE LEFT TO RIGHT
imagefilledrectangle($im, 0, 148, 300, 152, $green);
//NOW MAKE AN IMAGE, CAN BE
//PNG, GIF, OR JPEG, YOUR CHOICE
header("Content-type: image/jpeg");
//TAKE THAT HEADER AND MAKE THE IMAGE
imagejpeg($im);
//DESTROY IT FROM SERVER MEMORY
imagedestroy($im);
?>