note 31155 deleted from function.imagedashedline by didou
| From: | didou@php.net | Date: | Fri, 15 Aug 2003 22:30:08 +0000 |
| Subject: | note 31155 deleted from function.imagedashedline by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54278@lists.php.net to get a copy of this message | ||
Note Submitter: droszi@phantom.hu
----
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;
}
}
}