示例#1
0
 /**
  * Resize the image
  *
  * @param int   $new_x   New width
  * @param int   $new_y   New height
  * @param array $options Optional parameters
  *
  * @return bool|PEAR_Error TRUE on success or PEAR_Error object on error
  *
  * @access protected
  */
 function _resize($new_x, $new_y, $options = null)
 {
     if ($this->resized === true) {
         return PEAR::raiseError('You have already resized the image without saving it.' . ' Your previous resizing will be overwritten', null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);
     }
     if ($this->new_x == $new_x && $this->new_y == $new_y) {
         return true;
     }
     $xFactor = $new_x / $this->img_x;
     $yFactor = $new_y / $this->img_y;
     $outputSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, $new_x, $new_y);
     $outputContext = cairo_create($outputSurface);
     cairo_scale($outputContext, $xFactor, $yFactor);
     cairo_set_source_surface($outputContext, $this->surface, 0, 0);
     cairo_paint($outputContext);
     cairo_destroy($outputContext);
     cairo_surface_destroy($this->surface);
     $this->surface = $outputSurface;
     $this->new_x = $new_x;
     $this->new_y = $new_y;
     return true;
 }
示例#2
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();
     cairo_save($this->context);
     // Draw circular arc path
     $path = cairo_new_path($this->context);
     cairo_translate($this->context, $center->x, $center->y);
     cairo_scale($this->context, 1, $height / $width);
     cairo_arc($this->context, 0.0, 0.0, $width / 2, 0, 2 * M_PI);
     cairo_restore($this->context);
     $this->getStyle($color, $filled);
     cairo_stroke($this->context);
     // 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;
 }