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

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