note 19446 added to function.imagedashedline

From: Date: Wed, 27 Feb 2002 20:33:54 +0000
Subject: note 19446 added to function.imagedashedline
Groups: php.notes 
Request: Send a blank email to php-notes+get-27130@lists.php.net to get a copy of this message
Here is a simple code to draw a line with an arbitrary stroke. The parameter aStroke is treated as a cyclic boolean array where true equals "set a point" e.g. $aDotStroke = array(true,false); function ImageStrokeLine($im,$x1,$y1,$x2,$y2,$color, $aStroke) { $deltax = abs($x2 - $x1); $deltay = abs($y2 - $y1); $x = $x1; $y = $y1; if ($x2 >= $x1) { $xinc1 = 1; $xinc2 = 1; } else { $xinc1 = -1; $xinc2 = -1; } if ($y2 >= $y1) { $yinc1 = 1; $yinc2 = 1; } else { $yinc1 = -1; $yinc2 = -1; } if ($deltax >= $deltay) { $xinc1 = 0; $yinc2 = 0; $den = $deltax; $num = $deltax / 2; $numadd = $deltay; $numpixels = $deltax; } else { $xinc2 = 0; $yinc1 = 0; $den = $deltay; $num = $deltay / 2; $numadd = $deltax; $numpixels = $deltay; } for ($curpixel = 0; $curpixel <= $numpixels; $curpixel++) { if ($iStrokeCount >= count($aStroke)) { $iStrokeCount = 0; } if ($aStroke[$iStrokeCount++]) { ImageSetPixel($im,$x, $y,$color); } $num += $numadd; if ($num >= $den) { $num -= $den; $x += $xinc1; $y += $yinc1; } $x += $xinc2; $y += $yinc2; } } -- http://www.php.net/manual/en/function.imagedashedline.php http://master.php.net/manage/user-notes.php?action=edit+19446 http://master.php.net/manage/user-notes.php?action=delete+19446 http://master.php.net/manage/user-notes.php?action=reject+19446

« previous php.notes (#27130) next »