for loop limit?

From: Date: Sat, 27 May 2000 06:45:18 +0000
Subject: for loop limit?
Groups: php.dev 
Request: Send a blank email to php-dev+get-19576@lists.php.net to get a copy of this message
I am writing this crazy script to count something up for math class, and I can't seem to figure it out. I think that its a limitation of the for loop... The script is 45 lines total, and is below. If anyone is interested, I can attach the resulting png that I get.. the ** part is the suspect area... <? //declarations and creation $im = ImageCreateFromPNG("circle.png"); $black = ImageColorAt($im, 21, 200); $white = ImageColorAllocate($im, 255, 255, 255); $grey = ImageColorAllocate($im, 128, 128, 128); ImageFillToBorder($im, 1, 1, $black, $black); ImageFillToBorder($im, 200, 200, $black, $grey); // point/line section $r = 200-21; $deg = 360/$num; for($i = 0; $i < $num; $i++) { $x[$i] = (200 + (int)($r * cos(deg2rad($i*$deg)))); $y[$i] = (200 - (int)($r * sin(deg2rad($i*$deg)))); } for($i = 0; $i < $num; $i++) { for($j = 0; $j < $num; $j++) { ImageLine($im, $x[$i], $y[$i], $x[$j], $y[$j], $black); } } //count regions ** part that I think is causing the problem** $c=0; $xx=0; $yy=0; for ($xx=0; $xx<400; $xx++) for ($yy=0; $yy<400; $yy++) { if(ImageColorAt($im,$xx,$yy)==$grey) { ImageFillToBorder($im,$xx,$yy,$black,$white); $c=$c+1; } } } //output and cleanup ImageString($im, 3, 5, 3, "Circle w/ $num points", $white); ImageString($im, 3, 5, 15, "Counted $c regions", $white); header("Content-type: image/png"); ImagePNG($im); ImageDestroy($im); ?> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Theodore Baschak - Gecko Internet Services http://www.gecko-internet.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

« previous php.dev (#19576) next »