Source:
//+------------------------+
//| Pie3dfun. php//Common Functions |
//+------------------------+
Define ("Angle_step", 5); Defines the angle step when drawing an elliptical arc
function Draw_getdarkcolor ($img, $CLR)//$CLR the corresponding dark color
{
$rgb = Imagecolorsforindex ($img, $CLR);
return Array ($rgb ["Red"]/2, $rgb ["Green"]/2, $rgb ["Blue"]/2);
}
function draw_getexy ($a, $b, $d)//$d point coordinates on the ellipse corresponding to the angle
{
$d = Deg2rad ($d);
Return Array (round ($a *cos ($d)), round ($b *sin ($d)));
}
function Draw_arc ($img, $ox, $oy, $a, $b, $SD, $ed, $CLR)//Elliptical arc function
{
$n = Ceil (($ed-$SD)/angle_step);
$d = $SD;
List ($x 0, $y 0) = draw_getexy ($a, $b, $d);
for ($i =0; $i < $n; $i + +)
{
$d = ($d +angle_step) > $ed $ed:($d +angle_step);
List ($x, $y) = Draw_getexy ($a, $b, $d);
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $x + $ox, $y + $oy, $CLR);
$x 0 = $x;
$y 0 = $y;
}
}
function Draw_sector ($img, $ox, $oy, $a, $b, $SD, $ed, $CLR)//Draw slices
{
$n = Ceil (($ed-$SD)/angle_step);
$d = $SD;
List ($x 0, $y 0) = draw_getexy ($a, $b, $d);
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $ox, $oy, $CLR);
for ($i =0; $i < $n; $i + +)
{
$d = ($d +angle_step) > $ed $ed:($d +angle_step);
List ($x, $y) = Draw_getexy ($a, $b, $d);
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $x + $ox, $y + $oy, $CLR);
$x 0 = $x;
$y 0 = $y;
}
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $ox, $oy, $CLR);
List ($x, $y) = Draw_getexy ($a/2, $b/2, ($d + $sd)/2);
Imagefill ($img, $x + $ox, $y + $oy, $CLR);
}
http://www.bkjia.com/PHPjc/446994.html www.bkjia.com true http://www.bkjia.com/PHPjc/446994.html techarticle Source code://+------------------------+//| pie3dfun. php//Common Functions | +------------------------+ define ("Angle_step", 5); Defines the angle step function dra when drawing an elliptical arc ...