PHP LOOP ART

These codes were used to create the images on this page. The first code is the entire code for the image. The rest of the codes are the loops and lines used in the rest of the images, which were created just by substituting the loops and lines of the coding in the first image.

math1.php


$width = 250;
$height = 250;

$im = imagecreate($width,$height);
$background_color = imagecolorallocate($im, 0,0,0);
imagecolortransparent($im, $background_color);
$x1 = 0;
while ($x1 <= 250) {
$x1 = $x1 + 25;

$x2 = 0;
while ($x2 <= 250) {
$x2 = $x2 + 25;

$raycolor = imagecolorallocate($im, 255-$x1, 100, 255-$x1);
imagesetthickness($im, 7);
imageline($im,250-$x1, 250, 250-$x2, 0,$raycolor);
}
}
header("Content-type: image/gif");
imagegif($im);
imagedestroy($im);
?>

math2.php

$x1 = 20;
while ($x1 <= 250) {
$x1 = $x1 + 25;
$x2 = 20;
while ($x2 <= 250) {
$x2 = $x2 + 25;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1); imagesetthickness($im, 3);
imageline($im, 125+$x1, 125+$x2, 0, 0, $raycolor);
imageline($im, 125+$x1, 125-$x2, 0, 250, $raycolor);
imageline($im, 125-$x1, 125-$x2, 250, 250, $raycolor);
imageline($im, 125-$x1, 125+$x2, 250, 0, $raycolor);}}

math3.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, 0);
imagesetthickness($im, 3);
imageline($im, 0+$x1, 0+$x2, 250, 250, $raycolor);
imageline($im, 250-$x1, 250-$x2, 0, 0, $raycolor);
imageline($im, 250-$x1, 0+$x2, 0, 250, $raycolor);
imageline($im, 0+$x1, 250-$x2, 250, 0, $raycolor);}}

math4.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 3);
imageline($im, 0+$x1, 0+$x2, 250, 0, $raycolor);
imageline($im, 250-$x1, 0+$x2, 250, 250, $raycolor);
imageline($im, 0+$x1, 250-$x2, 0, 0, $raycolor);
imageline($im, 250-$x1, 250-$x2, 0, 250, $raycolor);}}

math5.php

$x1 = 0;
while ($x1 <= 250) {
$x1 = $x1 + 25;
$x2 = 0;
while ($x2 <= 250) {
$x2 = $x2 + 25;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 3);
imageline($im, 0, 125-$x2, 250, 125-$x1, $raycolor);
imageline($im, 0, 125+$x1, 250, 125+$x2,$raycolor);
imageline($im,125-$x2, 0, 125-$x1, 250, $raycolor);
imageline($im,125+$x1, 0,125+$x2, 250, $raycolor);}}

math6.php

$x1 = 0;
while ($x1 <= 250) {
$x1 = $x1 + 25;
$x2 = 0;
while ($x2 <= 250) {
$x2 = $x2 + 25;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 3);
imageline($im,125-$x2, 0, 125-$x1, 250, $raycolor);
imageline($im,125+$x1, 0, 125+$x2, 250, $raycolor);}}

math7.php

$x1 = -50;
while ($x1 <= 250) {
$x1 = $x1 + 60;
$x2 = -50;
while ($x2 <= 250) {
$x2 = $x2 + 60;
$raycolor = imagecolorallocate($im, $x1, $x2, 0);
imagesetthickness($im, 4);
imageline($im,125, 125, 240-$x1, 240-$x2, $raycolor);
imageline($im,125, 125, 10+$x1, 10+$x2, $raycolor)}}

math8.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, 0);
imagesetthickness($im, 4);
imageline($im, 125, 125, 0-$x1, 0-$x2, $raycolor);
imageline($im, 125, 125, 0-$x1, 250+$x2, $raycolor);
imageline($im, 125, 125, 250+$x1, 250+$x2, $raycolor);
imageline($im, 125, 125, 250+$x1, 0-$x2, $raycolor);}}

math9.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 4);
imageline($im, 125, 125, 0-$x1, 0-$x2, $raycolor);
imageline($im, 125, 125, 0-$x1, 250+$x2, $raycolor);
imageline($im, 125, 125, 250+$x1, 250+$x2, $raycolor);
imageline($im, 125, 125, 250+$x1, 0-$x2, $raycolor);}}

math10.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 4);
imageline($im, $x1, 250-$x2, 250, 0+$x1, $raycolor);}}

math11.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 4);
imageline($im, $x1, 250+$x2, 250-$x1, 0, $raycolor);}}

math12.php

$x1 = 0;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = 0;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 4);
imageline($im, 125+$x1, 125-$x2, 0, 0, $raycolor);
imageline($im, 125+$x1, 125+$x2, 250, 0, $raycolor);
imageline($im, 125-$x1, 125+$x2, 250, 250, $raycolor
); imageline($im, 125-$x1, 125-$x2, 0, 250, $raycolor);}}

math13.php

$x1 = 0;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = 0;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 4);
imageline($im, 125-$x1, 125+$x2, 0, 0, $raycolor);
imageline($im, 125-$x1, 125-$x2, 250, 0, $raycolor);
imageline($im, 125+$x1, 125-$x2, 250, 250, $raycolor);
imageline($im, 125+$x1, 125+$x2, 0, 250, $raycolor);}}

math14.php

$x1 = 0;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = 0;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, $x1);
imagesetthickness($im, 4);
imageline($im, 125+$x1, 125+$x2, 0, 0, $raycolor);
imageline($im, 125-$x1, 125+$x2, 250, 0, $raycolor);
imageline($im, 125-$x1, 125-$x2, 250, 250, $raycolor);
imageline($im, 125+$x1, 125-$x2, 0, 250, $raycolor);}}

math15.php

$x1 = -10;
while ($x1 <= 250) {
$x1 = $x1 + 10;
$x2 = -10;
while ($x2 <= 250) {
$x2 = $x2 + 10;
$raycolor = imagecolorallocate($im, 200-$x1, 0, 255-$x2);
imagesetthickness($im, 4);
imageline($im, 125-$x1, 125-$x2, 0, 0, $raycolor);
imageline($im, 125+$x1, 125-$x2, 250, 0, $raycolor);
imageline($im, 125+$x1, 125+$x2, 250, 250, $raycolor);
imageline($im, 125-$x1, 125+$x2, 0, 250, $raycolor);}}

math16.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, 100-$x1, 10, 200-$x2);
imagesetthickness($im, 3);
imageline($im, 125+$x1, 125+$x2, 250, 0, $raycolor);
imageline($im, 125+$x1, 125-$x2, 250, 250, $raycolor);
imageline($im, 125-$x1, 125+$x2, 0, 0, $raycolor);
imageline($im, 125-$x1, 125-$x2, 0, 250, $raycolor);}}

math17.php

$x1 = -10;
while ($x1 <= 250) {
$x1 = $x1 + 10;
$x2 = -10;
while ($x2 <= 250) {
$x2 = $x2 + 10;
$raycolor = imagecolorallocate($im, 255-$x1, 25+$x2, 100-$x1);
imagesetthickness($im, 4);
imageline($im, 125-$x1, 125-$x2, 0, 0, $raycolor);
imageline($im, 125+$x1, 125-$x2, 250, 0, $raycolor);
imageline($im, 125+$x1, 125+$x2, 250, 250, $raycolor);
imageline($im, 125-$x1, 125+$x2, 0, 250, $raycolor);}}

math18.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, 100-$x1, 200-$x2, 50);
imagesetthickness($im, 3);
imageline($im, 125+$x1, 125+$x2, 250, 0, $raycolor);
imageline($im, 125+$x1, 125-$x2, 250, 250, $raycolor);
imageline($im, 125-$x1, 125+$x2, 0, 0, $raycolor);
imageline($im, 125-$x1, 125-$x2, 0, 250, $raycolor);}}

math19.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, $x2, 0);
imagesetthickness($im, 3);
imageline($im, 0+$x1, 0+$x2, 250, 250, $raycolor);
imageline($im, 250-$x1, 250-$x2, 0, 0, $raycolor);

math20.php

$x1 = -20;
while ($x1 <= 250) {
$x1 = $x1 + 20;
$x2 = -20;
while ($x2 <= 250) {
$x2 = $x2 + 20;
$raycolor = imagecolorallocate($im, $x1, 100-$x2, 0);
imagesetthickness($im, 4);
imageline($im, $x1, 250+$x2, 250-$x1, 0, $raycolor);
imageline($im, 250-$x1, 250+$x2, $x1,0, $raycolor);}}
© 2006 LingoLinda.com