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 ...
<?php
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
}
?>
--was--
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
}
http://php.net/manual/en/function.imagearc.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.