note 42984 deleted from function.imageline by cmb
| From: | cmb@php.net | Date: | Fri, 15 Jul 2016 16:20:15 +0000 |
| Subject: | note 42984 deleted from function.imageline by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206025@lists.php.net to get a copy of this message | ||
Note Submitter: likavcan at NOSPAN sturak nospan dot sk
----
This function draws arrow.
function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color) {
$distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
$dx = $x2 + ($x1 - $x2) * $alength / $distance;
$dy = $y2 + ($y1 - $y2) * $alength / $distance;
$k = $awidth / $alength;
$x2o = $x2 - $dx;
$y2o = $dy - $y2;
$x3 = $y2o * $k + $dx;
$y3 = $x2o * $k + $dy;
$x4 = $dx - $y2o * $k;
$y4 = $dy - $x2o * $k;
imageline($im, $x1, $y1, $dx, $dy, $color);
imageline($im, $x3, $y3, $x4, $y4, $color);
imageline($im, $x3, $y3, $x2, $y2, $color);
imageline($im, $x2, $y2, $x4, $y4, $color);
}