예제 #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;
 }
예제 #2
0
<?php

$sur = new CairoImageSurface(CairoFormat::ARGB32, 120, 100);
$con = new CairoContext($sur);
$con->setSourceRgb(1, 1, 1);
$con->paint();
$con->setSourceRgb(0, 0, 0);
$con->setMiterLimit(100000);
for ($xscale = 1; $xscale <= 1000; $xscale += 999) {
    for ($yscale = 1; $yscale <= 1000; $yscale += 999) {
        //$max_scale = ($xscale > $yscale) ? $xscale : $yscale;
        $max_scale = max($xscale, $yscale);
        $con->save();
        if ($xscale > 1) {
            $con->translate(50, 0);
        }
        if ($yscale > 1) {
            $con->translate(0, 50);
        }
        $con->scale($xscale, $yscale);
        $con->setLineWidth(10.0 / $max_scale);
        $con->moveTo(10.0 / $xscale, 10.0 / $yscale);
        $con->lineTo(40.0 / $xscale, 10.0 / $yscale);
        $con->lineTo(10.0 / $xscale, 30.0 / $yscale);
        $con->stroke();
        $con->restore();
    }
}
$sur->writeToPng(dirname(__FILE__) . "/miter-precision-php.png");
예제 #3
0
 $con->lineTo($x, $y + $height);
 $con->clip();
 switch ($i) {
     case 0:
         $wi = floor($width * 0.9);
         $he = floor($height * 0.9);
         $x += 0.05 * $width;
         $y += 0.05 * $height;
         //$stemp = $con->get_group_target();
         $msur = $sur->createSimilar(CairoContent::ALPHA, $wi, $he);
         $c2 = new CairoContext($msur);
         $c2->save();
         $c2->setSourceRgba(0, 0, 0, 0);
         $c2->setOperator(CairoOperator::SOURCE);
         $c2->paint();
         $c2->restore();
         $c2->setSourceRgb(1, 1, 1);
         $c2->arc(0.5 * $wi, 0.5 * $he, 0.45 * $he, 0, 2 * M_PI);
         $c2->fill();
         //unset($c2);
         $con->maskSurface($msur, $x, $y);
         //unset($msur);
         //unset($stemp);
         break;
     case 1:
         $con->setFontSize(0.9 * $height);
         $ext = $con->textExtents("FG");
         $con->moveTo($x + floor(($width - $ext["width"]) / 2 + 0.5) - $ext["x_bearing"], $y + floor(($height - $ext["height"]) / 2 + 0.5) - $ext["y_bearing"]);
         $con->showText("FG");
         break;
     case 2: