note 102762 added to function.imagearc
| From: | Michael at osu1 dot php dot net | Date: | Fri, 04 Mar 2011 10:56:57 +0000 |
| Subject: | note 102762 added to function.imagearc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177554@lists.php.net to get a copy of this message | ||
Hi, this is a function that replaces "imagearc" to solve the thickness-problem. it does
not use the global value set by imagesetthickness, so you have to pass it along.
"connecting" the arc to lines is still a problem, it sometimes shifts by 1px, but so does
the original function.
Theres still alot to improve ...
function myimagearc($im,$mid_x,$mid_y,$rad,$w1,$w2,$col,$thickness){
global $cols;
$rad+=$thickness/2; // to calculate outer edge
$th_fact = 1-((($thickness-1)/$rad));
$pts = 36*$rad; // adjust density
$fact = $pts/360;
$w1 = $w1*$fact;
$w2 = $w2*$fact;
if($thickness > 2) // to make sure we have neither gaps nor ugly looking artefacts
imagesetthickness($handle,2);
else
imagesetthickness($handle,1);
$winkel = (2*pi())/$pts;
for($i=$w1+1;$i< $w2;$i++){
$x = (cos($i*$winkel)*($rad));
$y = (sin($i*$winkel)*($rad));
$x1 = $x+$mid_x;
$y1 = $y+$mid_y;
$x2 = $th_fact*$x+$mid_x;
$y2 = $th_fact*$y+$mid_y;
imageline($im, $x1,$y1,$x2,$y2,$col);
}
imagesetthickness($handle,1); // just to reset
}
----
Server IP: 69.147.83.197
Probable Submitter: 213.160.28.110
----
Manual Page -- http://www.php.net/manual/en/function.imagearc.php
Edit -- https://master.php.net/note/edit/102762
Del: integrated -- https://master.php.net/note/delete/102762/integrated
Del: useless -- https://master.php.net/note/delete/102762/useless
Del: bad code -- https://master.php.net/note/delete/102762/bad+code
Del: spam -- https://master.php.net/note/delete/102762/spam
Del: non-english -- https://master.php.net/note/delete/102762/non-english
Del: in docs -- https://master.php.net/note/delete/102762/in+docs
Del: other reasons-- https://master.php.net/note/delete/102762
Reject -- https://master.php.net/note/reject/102762
Search -- https://master.php.net/manage/user-notes.php