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
//$s = new CairoImageSurface(FORMATARGB32, $width, $height);
$con->translate($pad, $pad);
$pat_surface = $sur->createSimilar(CairoContent::COLOR_ALPHA, $patwidth, $patheight);
$cr2 = new CairoContext($pat_surface);
$cr2->setSourceRgba(1, 0, 1, 0.5);
$cr2->rectangle($patwidth / 6.0, $patheight / 6.0, $patwidth / 4.0, $patheight / 4.0);
$cr2->fill();
$cr2->setSourceRgba(0, 1, 1, 0.5);
$cr2->rectangle($patwidth / 2.0, $patheight / 2.0, $patwidth / 4.0, $patheight / 4.0);
$cr2->fill();
$cr2->setLineWidth(1);
$cr2->moveTo($patwidth / 6.0, 0);
$cr2->lineTo(0, 0);
$cr2->lineTo(0, $patheight / 6.0);
$cr2->setSourceRgb(1, 0, 0);
$cr2->stroke();
$cr2->moveTo($patwidth / 6.0, $patheight);
$cr2->lineTo(0, $patheight);
$cr2->lineTo(0, 5 * $patheight / 6.0);
$cr2->setSourceRgb(0, 1, 0);
$cr2->stroke();
$cr2->moveTo(5 * $patwidth / 6.0, 0);
$cr2->lineTo($patwidth, 0);
$cr2->lineTo($patwidth, $patheight / 6.0);
$cr2->setSourceRgb(0, 0, 1);
$cr2->stroke();
$cr2->moveTo(5 * $patwidth / 6.0, $patheight);
$cr2->lineTo($patwidth, $patheight);
$cr2->lineTo($patwidth, 5 * $patheight / 6.0);
$cr2->setSourceRgb(1, 1, 0);
$cr2->stroke();
Ejemplo n.º 3
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");
Ejemplo n.º 4
0
<?php

$s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100);
$c = new CairoContext($s);
$c->setSourceRgb(0, 0, 0);
$c->paint();
$c->setLineWidth(1);
$c->setSourceRgb(1, 1, 1);
for ($r = 50; $r > 0; $r -= 10) {
    $c->arc(50, 50, $r, 0, 2 * M_PI);
    $c->stroke();
    $c->fill();
}
$s->writeToPng(dirname(__FILE__) . '/CairoContext__arc.png');