note 89971 deleted from function.imageline by cmb
| From: | cmb@php.net | Date: | Fri, 15 Jul 2016 16:19:48 +0000 |
| Subject: | note 89971 deleted from function.imageline by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206024@lists.php.net to get a copy of this message | ||
Note Submitter: ca dot ddy at gmx dot de
----
I've modified the Arrow function of likavcan.
This arrowFunction draws the arrow filled :
<?php
function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color) {
if( $alength > 1 )
arrow( $im, $x1, $y1, $x2, $y2, $alength - 1, $awidth - 1, $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);
}
?>