note 89971 modified in function.imageline by danbrown

From: Date: Tue, 31 Mar 2009 18:00:14 +0000
Subject: note 89971 modified in function.imageline by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152655@lists.php.net to get a copy of this message
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); } ?> --was-- I've modified the Arrow function of likavcan. This arrowFunction draws the arrow filled : 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); } http://php.net/manual/en/function.imageline.php

« previous php.notes (#152655) next »