Ejemplo n.º 1
0
 /**
  * Draw circle 
  * 
  * @param ezcGraphCoordinate $center Center of ellipse
  * @param mixed $width Width of ellipse
  * @param mixed $height height of ellipse
  * @param ezcGraphColor $color Color
  * @param mixed $filled Filled
  * @return void
  */
 public function drawCircle(ezcGraphCoordinate $center, $width, $height, ezcGraphColor $color, $filled = true)
 {
     $this->initiliazeSurface();
     $this->context->save();
     // Draw circular arc path
     $this->context->newPath();
     $this->context->translate($center->x, $center->y);
     $this->context->scale(1, $height / $width);
     $this->context->arc(0.0, 0.0, $width / 2, 0, 2 * M_PI);
     $this->context->restore();
     $this->getStyle($color, $filled);
     $this->context->stroke();
     // Create polygon array to return
     $polygonArray = array();
     for ($angle = 0; $angle < 2 * M_PI; $angle += deg2rad($this->options->imageMapResolution)) {
         $polygonArray[] = new ezcGraphCoordinate($center->x + cos($angle) * $width / 2, $center->y + sin($angle) * $height / 2);
     }
     return $polygonArray;
 }
Ejemplo n.º 2
0
<?php

$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();