Exemplo n.º 1
0
 public function testShouldPlaceText()
 {
     $resource = $this->getMockBuilder('Imanee\\ImageResource\\GDResource')->setMethods(['annotate'])->getMock();
     $resource->expects($this->at(0))->method('annotate')->with('testing');
     $drawer = $this->getMockBuilder('Imanee\\Drawer')->setMethods(['setFontSize'])->getMock();
     $drawer->expects($this->any())->method('setFontSize');
     $this->model->setDrawer($drawer);
     $this->model->setResource($resource);
     $this->model->placeText('testing');
     $this->model->placeText('testing', Imanee::IM_POS_MID_RIGHT, 10, 500);
 }
Exemplo n.º 2
0
 /**
  * Convenient method for generating text-only images
  *
  * @param string $text
  * @param Drawer $drawer
  * @param string $format
  * @param string $background
  * @return Imanee
  */
 public static function textGen($text, Drawer $drawer = null, $format = 'png', $background = 'transparent', ImageResourceInterface $resource = null)
 {
     $imanee = new Imanee(null, $resource);
     if ($drawer !== null) {
         $imanee->setDrawer($drawer);
     }
     $size = $imanee->resource->getTextGeometry($text, $imanee->getDrawer());
     $imanee->newImage($size['width'], $size['height'], $background);
     $imanee->setFormat($format);
     $imanee->placeText($text, Imanee::IM_POS_TOP_LEFT);
     return $imanee;
 }