/** * Draws a circular arc consisting of several minor steps on the bounding * lines. * * @param ezcGraphCoordinate $center * @param mixed $width * @param mixed $height * @param mixed $size * @param mixed $startAngle * @param mixed $endAngle * @param ezcGraphColor $color * @param bool $filled * @return string Element id */ protected function simulateCircularArc(ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled) { for ($tmpAngle = min(ceil($startAngle / 180) * 180, $endAngle); $tmpAngle <= $endAngle; $tmpAngle = min(ceil($startAngle / 180 + 1) * 180, $endAngle)) { $this->context->newPath(); $this->context->moveTo($center->x + cos(deg2rad($startAngle)) * $width / 2, $center->y + sin(deg2rad($startAngle)) * $height / 2); // @TODO: Use cairo_curve_to() for ($angle = $startAngle; $angle <= $tmpAngle; $angle = min($angle + $this->options->circleResolution, $tmpAngle)) { $this->context->lineTo($center->x + cos(deg2rad($angle)) * $width / 2, $center->y + sin(deg2rad($angle)) * $height / 2 + $size); if ($angle === $tmpAngle) { break; } } for ($angle = $tmpAngle; $angle >= $startAngle; $angle = max($angle - $this->options->circleResolution, $startAngle)) { $this->context->lineTo($center->x + cos(deg2rad($angle)) * $width / 2, $center->y + sin(deg2rad($angle)) * $height / 2); if ($angle === $startAngle) { break; } } $this->context->closePath(); $this->getStyle($color, $filled); $this->context->stroke(); $startAngle = $tmpAngle; if ($tmpAngle === $endAngle) { break; } } }
$width = 64; $height = 64; $sur = new CairoImageSurface(CairoFormat::ARGB32, $width, $height); $con = new CairoContext($sur); $con->newPath(); $con->arc($width / 2, $height / 2, $width / 3, 0, 2 * M_PI); $con->clip(); $con->newPath(); $con->moveTo(0, 0); $con->lineTo($width / 4, $height / 2); $con->lineTo(0, $height); $con->lineTo($width, $height); $con->lineTo(3 * $width / 4, $height / 2); $con->lineTo($width, 0); $con->closePath(); $con->clip(); $con->setSourceRgb(0, 0, 0.6); $con->newPath(); $con->moveTo(0, 0); $con->lineTo(0, $height); $con->lineTo($width / 2, 3 * $height / 4); $con->lineTo($width, $height); $con->lineTo($width, 0); $con->lineTo($width / 2, $height / 4); $con->closePath(); $con->fill(); $con->newPath(); $con->arc($width / 2, $height / 2, $width / 5, 0, 2 * M_PI); $con->clip(); $con->setSourceRgb(1, 1, 0);