note 31155 added to function.imagedashedline

From: Date: Fri, 11 Apr 2003 11:27:10 +0000
Subject: note 31155 added to function.imagedashedline
Groups: php.notes 
Request: Send a blank email to php-notes+get-46492@lists.php.net to get a copy of this message
With this function you can draw dotted lines in any angle on image png from x1,y1 to x2,y2 with color color and dist pixel distance from each other. function ImageDottedLine ($png, $x1, $y1, $x2, $y2, $color, $dist) { if (($y2 - $y1) != 0) { $dx = $dist * cos (atan(($x2 - $x1) / ($y2 - $y1))); $dy = $dist * sin (atan(($x2 - $x1) / ($y2 - $y1))); } else { $dx = $dist; $dy = 0; } if (($x2 - $x1) != 0) { $dy = $dist * sin (atan(($y2 - $y1) / ($x2 - $x1))); $dx = $dist * cos (atan(($y2 - $y1) / ($x2 - $x1))); } else { $dy=$dist; $dx=0; } $x = $x1; $y = $y1; if (($x1 - $x2) != 0) { while ($x < $x2) { ImageSetPixel($png, $x, $y, $color); $x+=$dx; $y+=$dy; } } else if(($y1 - $y2) != 0) { while ($y < $y2) { ImageSetPixel($png, $x, $y, $color); $x+=$dx; $y+=$dy; } } } -- http://www.php.net/manual/en/function.imagedashedline.php http://master.php.net/manage/user-notes.php?action=edit+31155 http://master.php.net/manage/user-notes.php?action=delete+31155 http://master.php.net/manage/user-notes.php?action=reject+31155

« previous php.notes (#46492) next »