public function drawArc($x, $y, $start, $end, $w, $h = null)
{
if (null === $h) {
$h = $w;
}
$sX = round($w * cos($start / 180 * pi()));
$sY = round($h * sin($start / 180 * pi()));
$eX = round($w * cos($end / 180 * pi()));
$eY = round($h * sin($end / 180 * pi()));
$centerPoint = array('x' => $x, 'y' => $y);
$startPoint = array('x' => $x + $sX, 'y' => $y + $sY);
$endPoint = array('x' => $x + $eX, 'y' => $y + $eY);
$startQuad = $this->getQuadrant($startPoint, $centerPoint);
$endQuad = $this->getQuadrant($endPoint, $centerPoint);
$corner1 = array('x' => $this->width, 'y' => $this->height);
$corner2 = array('x' => 0, 'y' => $this->height);
$corner3 = array('x' => 0, 'y' => 0);
$corner4 = array('x' => $this->width, 'y' => 0);
$polyPoints = array($centerPoint, $startPoint);
switch ($startQuad) {
case 1:
if ($endQuad == 1) {
$polyPoints[] = $corner1;
$polyPoints[] = array('x' => $endPoint['x'], 'y' => $this->height);
} else {
if ($endQuad == 2) {
$polyPoints[] = $corner1;
$polyPoints[] = $corner2;
} else {
if ($endQuad == 3) {
$polyPoints[] = $corner1;
$polyPoints[] = $corner2;
$polyPoints[] = $corner3;
} else {
if ($endQuad == 4) {
$polyPoints[] = $corner1;
$polyPoints[] = $corner2;
$polyPoints[] = $corner3;
$polyPoints[] = $corner4;
}
}
}
}
break;
case 2:
if ($endQuad == 1) {
$polyPoints[] = $corner2;
$polyPoints[] = $corner3;
$polyPoints[] = $corner4;
$polyPoints[] = $corner1;
} else {
if ($endQuad == 2) {
$polyPoints[] = $corner2;
$polyPoints[] = array('x' => 0, 'y' => $endPoint['y']);
} else {
if ($endQuad == 3) {
$polyPoints[] = $corner2;
$polyPoints[] = $corner3;
} else {
if ($endQuad == 4) {
$polyPoints[] = $corner2;
$polyPoints[] = $corner3;
$polyPoints[] = $corner4;
}
}
}
}
break;
case 3:
if ($endQuad == 1) {
$polyPoints[] = $corner3;
$polyPoints[] = $corner4;
$polyPoints[] = $corner1;
} else {
if ($endQuad == 2) {
$polyPoints[] = $corner3;
$polyPoints[] = $corner4;
$polyPoints[] = $corner1;
$polyPoints[] = $corner2;
} else {
if ($endQuad == 3) {
$polyPoints[] = $corner3;
$polyPoints[] = array('x' => $endPoint['x'], 'y' => 0);
} else {
if ($endQuad == 4) {
$polyPoints[] = $corner3;
$polyPoints[] = $corner4;
}
}
}
}
break;
case 4:
if ($endQuad == 1) {
$polyPoints[] = $corner4;
$polyPoints[] = $corner1;
} else {
if ($endQuad == 2) {
$polyPoints[] = $corner4;
$polyPoints[] = $corner1;
$polyPoints[] = $corner2;
} else {
if ($endQuad == 3) {
$polyPoints[] = $corner4;
$polyPoints[] = $corner1;
$polyPoints[] = $corner2;
$polyPoints[] = $corner3;
} else {
if ($endQuad == 4) {
$polyPoints[] = $corner4;
$polyPoints[] = array('x' => $this->width, 'y' => $endPoint['y']);
}
}
}
}
break;
}
$polyPoints[] = $endPoint;
$stamp = rand();
$defs = $this->resource->addChild('defs');
$clip = $defs->addChild('clipPath');
$clip->addAttribute('id', 'polyClip' . $stamp);
$formattedPoints = array();
foreach ($polyPoints as $point) {
$formattedPoints[] = $point['x'] . ',' . $point['y'];
}
$poly = $clip->addChild('polygon');
$poly->addAttribute('points', implode(' ', $formattedPoints));
$ellipse = $this->resource->addChild('ellipse');
$ellipse->addAttribute('style', 'clip-path: url(#polyClip' . $stamp . ');');
$ellipse->addAttribute('cx', $x . $this->units);
$ellipse->addAttribute('cy', $y . $this->units);
$ellipse->addAttribute('rx', $w . $this->units);
$ellipse->addAttribute('ry', (null === $h ? $w : $h) . $this->units);
$ellipse = $this->setStyles($ellipse);
return $this;
}