Hello,

If you have time, please run the code below. It is a very simple code
which has 2 nested loops and assigns colors to a given value. If the
product of $i and $j is smaller or equal to 256 (exactly the number of
colors allowed), then  you'll get a random pattern. If this product is
bigger than 256, then the last rows (i.e. all those cells with indexes
bigger than 256) of the rectangle will have the last
color encountered (as if is the 256'th), even though I only have 13
possible colors in the code.

Anybody has an indea to overcome this thing? Am I missing something, or
this is due to a problem in PHP (PHP 4.2.1, Win 2k), or GD?
I spent 3 days on this problem with no avail!

Thanks!

Mihai
 ---
<?php
$image=imageCreate(500,500);
$white=imageColorAllocate($image,255,255,255);
imageFilledRectangle($image,0,0,500,500,$white);
for ($i=0; $i<17; $i++) {
for ($j=0; $j<17; $j++) {
$qq=rand(0,13);
if ($qq==1) {
$vstrong=imageColorAllocate($image, 255, 0, 0);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$vstrong);
}
elseif ($qq==0) {
$nueste=imageColorAllocate($image, 255, 255, 0);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$nueste);
}
elseif ($qq==2) {
$strong=imageColorAllocate($image, 255, 0, 100);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$strong);
}
elseif ($qq==3) {
$smoderate=imageColorAllocate($image, 255, 100, 100);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$smoderate);
}
elseif ($qq==4) {
$moderate=imageColorAllocate($image, 255, 210, 100);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$moderate);
}
elseif ($qq==5) {
$color3=imageColorAllocate($image, 0, 255, 255);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$color3);
}
elseif ($qq==6) {
$color4=imageColorAllocate($image, 0, 255, 200);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$color4);
}
elseif ($qq==7) {
$color5=imageColorAllocate($image, 0, 100, 255);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$color5);
}

elseif ($qq==8) {
$color6=imageColorAllocate($image, 0, 100, 200);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$color6);
}
elseif ($qq==9) {
$color7=imageColorAllocate($image, 200, 0, 0);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$color7);
}
elseif ($qq==12) {
$justis=imageColorAllocate($image, 0, 0, 138);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$justis);
}
else {
$ciudat=imageColorAllocate($image, 0, 0, 255);
imagefilledrectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$ciudat);
}

}
}
Header("Content-type: image/png");
imagePNG($image);
imageDestroy($image);
?>
---




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to