Example #1
0
 /**
  * Обрезает изображение
  * @param Boundary $s Границы области обрезки
  * @throws GDException 
  * @return GDImage
  */
 function crop(Boundary $s)
 {
     if (($r = @imagecreatetruecolor($s->width(), $s->height())) === FALSE) {
         throw new GDException('Невозможно инициализировать GD поток');
     }
     @imagealphablending($r, false);
     if (!@imagecopy($r, $this->handle, 0, 0, $s->left(), $s->top(), $s->width(), $s->height())) {
         @imagedestroy($r);
         throw new GDException("Не удалось растянуть изображение.");
     }
     @imagealphablending($r, true);
     @imagedestroy($this->handle);
     $this->handle = $r;
     return $this;
 }
Example #2
0
 protected function getValuesArea(Boundary $b)
 {
     $dy = $this->getD()->width;
     $dx = $this->getD()->height;
     $h = $this->axis['font_x']->getTextExtent($this->maxleg)->height;
     $dbottom = $b->bottom() - ($h < $dx * 4 ? $dx * 4 : $h);
     $dleft = $b->left() + $this->axis['font_y']->getTextExtent($this->max)->width + $dy * 2;
     $dtop = $b->top() + $this->depth;
     $dright = $b->right() + $this->depth;
     return new Boundary($dleft, $dtop, $dright, $dbottom);
 }
Example #3
0
 function drawTitle($image, Boundary $b)
 {
     $s = $this->title['font']->getTextExtent($this->title['text']);
     //var_dump(imagettfbbox($this->title['font']->size,$this->title['font']->angle,$this->title['font']->family,$this->title['text']));
     //throw new exception ($s->height);
     if ($s->height > $b->height() || $s->width > $b->width()) {
         throw new ChartException("Недостаточно места для вывода заголовка.");
     }
     $b->bottom($b->top() + $s->height);
     $title = new Label($b, $this->title['text'], $this->title['font'], $this->title['color'], Label::ALIGN_CENTER_TOP);
     $title->draw($image);
 }