note 34712 added to function.imagearc

From: Date: Tue, 05 Aug 2003 01:19:41 +0000
Subject: note 34712 added to function.imagearc
Groups: php.notes 
Request: Send a blank email to php-notes+get-53365@lists.php.net to get a copy of this message
Heres a function to make a curve between two points... This will be a downward curve but it wouldn't be hard to make a similar function to make an upward curve. The first point has to be to the left of the second point ($x1 < $x2), and height is actually backwards. The larger height is the less of a crest the curve has. I imagine with a few modifications this functions could make upward curves as well. function ImageCurveDown ($image, $x1, $y1, $x2, $y2, $height, $color) { $presicion = 1; for ($left = ($x1-$x2); $left < 0; $left++){ if ($y1 < $y2) { $cy = $y2 + $height; $cx = $x1 - $left; } else { $cy = $y1 + $height; $cx = $x2 + $left; } $nx1 = abs($x1 - $cx); $ny1 = abs($y1 - $cy); $nx2 = abs($x2 - $cx); $ny2 = abs($y2 - $cy); if ($y1 < $y2) { if ($nx2 == 0 || $ny1 == 0) continue; $angle1 = atan($height/$nx2); $A1 = $nx2/cos ($angle1); $B1 = $ny2/sin ($angle1); $angle2 = pi()/2 +atan($left/$ny1); $A2 = $nx1/cos ($angle2); $B2 = $ny1/sin ($angle2); } else { if ($ny2 == 0 || $nx1 == 0) continue; $angle1 = atan($ny2/$nx2); $A1 = abs($nx2/cos ($angle1)); $B1 = abs($ny2/sin ($angle1)); $angle2 = atan($height/$nx1); $A2 = abs ($nx1/cos ($angle2)); $B2 = abs($ny1/sin ($angle2)); } if (abs($A1 - $A2) < $presicion && abs ($B1 - $B2) < $presicion) { ImageArc($image, $cx, $cy, $A1*2, $B1*2, 180+rad2deg($angle2), 360-rad2deg($angle1), $color); } } } ---- Manual Page -- http://www.php.net/manual/en/function.imagearc.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34712 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34712&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34712&report=yes

« previous php.notes (#53365) next »