/**
* Draws an arc.
*
* @param integer $x The x coordinate of the centre.
* @param integer $y The y coordinate of the centre.
* @param integer $r The radius of the arc.
* @param integer $start The start angle of the arc.
* @param integer $end The end angle of the arc.
* @param string $color The line color of the arc.
* @param string $fill The fill color of the arc (defaults to none).
*/
public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none')
{
// Split up arcs greater than 180 degrees into two pieces.
$this->_postSrcOperations[] = "-stroke {$color} -fill {$fill}";
$mid = round(($start + $end) / 2);
$x = round($x);
$y = round($y);
$r = round($r);
if ($mid > 90) {
$this->_postSrcOperations[] = "-draw \"ellipse {$x},{$y} {$r},{$r} {$start},{$mid}\"";
$this->_postSrcOperations[] = "-draw \"ellipse {$x},{$y} {$r},{$r} {$mid},{$end}\"";
} else {
$this->_postSrcOperations[] = "-draw \"ellipse {$x},{$y} {$r},{$r} {$start},{$end}\"";
}
// If filled, draw the outline.
if (!empty($fill)) {
list($x1, $y1) = Horde_Image::circlePoint($start, $r * 2);
list($x2, $y2) = Horde_Image::circlePoint($mid, $r * 2);
list($x3, $y3) = Horde_Image::circlePoint($end, $r * 2);
$verts = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
if ($mid > 90) {
$verts1 = array(array('x' => $x + round($x2), 'y' => $y + round($y2)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
$verts2 = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x2), 'y' => $y + round($y2)));
$this->polygon($verts1, $fill, $fill);
$this->polygon($verts2, $fill, $fill);
} else {
$this->polygon($verts, $fill, $fill);
}
$this->polyline($verts, $color);
$this->_postSrcOperations[] = '-stroke none -fill none';
}
}