note 19446 deleted from function.imagedashedline by didou

From: Date: Fri, 15 Aug 2003 22:29:47 +0000
Subject: note 19446 deleted from function.imagedashedline by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54276@lists.php.net to get a copy of this message
Note Submitter: kramesch_NOSPAM_@_nospam_idsolutions.at ---- 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; } }

« previous php.notes (#54276) next »