Image_3D
[ class tree: Image_3D ] [ index: Image_3D ] [ all elements ]

Source for file ImageCanvas.php

Documentation is available at ImageCanvas.php

  1. <?php
  2.  
  3. require_once 'Image/Canvas.php';
  4.  
  5.     
  6.     protected $_filetype;
  7.     protected $_type;
  8.  
  9.     public function __construct({
  10.         parent::__construct();
  11.     }
  12.     
  13.     public function setImageType($type{
  14.         $this->_type = (string) $type;
  15.     }
  16.     
  17.     public function createImage($x$y{
  18.         $this->_image = Image_Canvas::factory($this->_typearray('width' => $x'height' => $y'antialias' => 'driver'));
  19.     }
  20.     
  21.     protected function _getColor(Image_3D_Color $color{
  22.         $values $color->getValues();
  23.         return sprintf('#%02x%02x%02x@%f'(int) ($values[0* 255)(int) ($values[1* 255)(int) ($values[2* 255)1 - $values[3]);
  24.     }
  25.     
  26.     public function setBackground(Image_3D_Color $color{
  27.         $this->_image->setFillColor($this->_getColor($color));
  28.         $this->_image->rectangle(array('x0' => 0'y0' => 0'x1' => $this->_image->getWidth()'y1' => $this->_image->getHeight()));
  29.     }
  30.     
  31.     public function drawPolygon(Image_3D_Polygon $polygon{
  32.         
  33.         // Build pointarray
  34.         $pointArray = array();
  35.         $points $polygon->getPoints();
  36.         foreach ($points as $point{
  37.             $screenCoordinates $point->getScreenCoordinates();
  38.             $this->_image->addVertex(array('x' => $screenCoordinates[0]'y' => $screenCoordinates[1]));
  39.         }
  40.         $this->_image->setFillColor($this->_getColor($polygon->getColor()));
  41.         $this->_image->setLineColor(false);
  42.         $this->_image->polygon(array('connect' => true));
  43.     }
  44.     
  45.     public function drawGradientPolygon(Image_3D_Polygon $polygon{
  46.         $this->drawPolygon($polygon);
  47.     }
  48.     
  49.     public function save($file{
  50.         $this->_image->save(array('filename' => $file));
  51.     }
  52.  
  53.     public function getSupportedShading({
  54.         return array(Image_3D_Renderer::SHADE_NOImage_3D_Renderer::SHADE_FLAT);
  55.     }
  56. }
  57.  
  58. ?>

Documentation generated on Mon, 11 Mar 2019 14:38:28 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.