Re: for loop limit?
| From: | Jose de Leon | Date: | Sun, 28 May 2000 16:42:47 +0000 |
| Subject: | Re: for loop limit? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-19639@lists.php.net to get a copy of this message | ||
If this is your complete code, then it is obvious the problem. $num is not
properly initialized before the for loop is begun.
Jose
----- Original Message -----
From: "Theodore" <theodore@mygecko.net>
To: "Php-Dev@Lists. Php. Net (E-mail)" <php-dev@lists.php.net>
Sent: Friday, May 26, 2000 11:45 PM
Subject: [PHP-DEV] for loop limit?
> 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...
>
> <?
> file://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);
> }
> }
>
> file://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;
> }
> }
> }
>
> file://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
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>