Esempio n. 1
0
 public function testCreateTranslatedRotation()
 {
     $transformation = new ezcGraphRotation(90, new ezcGraphCoordinate(10, 10));
     $matrix = new ezcGraphMatrix(3, 3, array(array(0, 1, 0), array(-1, 0, 0), array(0, 0, 1)));
     $testCoordinate = new ezcGraphCoordinate(0, 0);
     $testCoordinate = $transformation->transformCoordinate($testCoordinate);
     $this->assertEquals(new ezcGraphCoordinate(20, 0), $testCoordinate, 'Transformation matrices are not aequivalent', 0.0001);
 }
Esempio n. 2
0
 /**
  * Draw text
  *
  * Draws the provided text in the boundings
  * 
  * @param ezcGraphBoundings $boundings Boundings of text
  * @param string $text Text
  * @param int $align Alignement of text
  * @param ezcGraphRotation $rotation
  * @return void
  */
 public function drawText(ezcGraphBoundings $boundings, $text, $align = ezcGraph::LEFT, ezcGraphRotation $rotation = null)
 {
     if ($this->depth === false) {
         // We are not 3d for now, wg. rendering normal text boxes like the
         // title
         $topleft = new ezcGraphCoordinate($boundings->x0, $boundings->y0);
         $bottomright = new ezcGraphCoordinate($boundings->x1, $boundings->y1);
     } else {
         // The 3d part started
         $topleft = $this->get3dCoordinate(new ezcGraphCoordinate($boundings->x0, $boundings->y0), false);
         $bottomright = $this->get3dCoordinate(new ezcGraphCoordinate($boundings->x1, $boundings->y1), false);
         // Also modify rotation accordingly
         if ($rotation !== null) {
             $rotation = new ezcGraphRotation($rotation->getRotation(), $this->get3dCoordinate($rotation->getCenter(), false));
         }
     }
     $this->driver->drawTextBox($text, $topleft, $bottomright->x - $topleft->x, $bottomright->y - $topleft->y, $align, $rotation);
 }
Esempio n. 3
0
 /**
  * Render text depending of font type and available font extensions
  * 
  * @param resource $image Image resource
  * @param string $text Text
  * @param int $type Font type
  * @param string $path Font path
  * @param ezcGraphColor $color Font color
  * @param ezcGraphCoordinate $position Position
  * @param float $size Textsize
  * @param ezcGraphRotation $rotation
  *
  * @return void
  */
 protected function renderText($image, $text, $type, $path, ezcGraphColor $color, ezcGraphCoordinate $position, $size, ezcGraphRotation $rotation = null)
 {
     if ($rotation !== null) {
         // Rotation is relative to top left point of text and not relative
         // to the bounding coordinate system
         $rotation = new ezcGraphRotation($rotation->getRotation(), new ezcGraphCoordinate($rotation->getCenter()->x - $position->x, $rotation->getCenter()->y - $position->y));
     }
     switch ($type) {
         case ezcGraph::PS_FONT:
             imagePsText($image, $text, $this->psFontRessources[$path], $size, $this->allocate($color), 1, $position->x + ($rotation === null ? 0 : $rotation->get(0, 2)), $position->y + ($rotation === null ? 0 : $rotation->get(1, 2)), 0, 0, $rotation === null ? 0 : -$rotation->getRotation(), 4);
             break;
         case ezcGraph::TTF_FONT:
             switch (true) {
                 case ezcBaseFeatures::hasFunction('imagefttext') && !$this->options->forceNativeTTF:
                     imageFtText($image, $size, $rotation === null ? 0 : -$rotation->getRotation(), $position->x + ($rotation === null ? 0 : $rotation->get(0, 2)), $position->y + ($rotation === null ? 0 : $rotation->get(1, 2)), $this->allocate($color), $path, $text);
                     break;
                 case ezcBaseFeatures::hasFunction('imagettftext'):
                     imageTtfText($image, $size, $rotation === null ? 0 : -$rotation->getRotation(), $position->x + ($rotation === null ? 0 : $rotation->get(0, 2)), $position->y + ($rotation === null ? 0 : $rotation->get(1, 2)), $this->allocate($color), $path, $text);
                     break;
             }
             break;
     }
 }