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

Source for file GD.php

Documentation is available at GD.php

  1. <?php
  2.  
  3. class Image_3D_Driver_GD extends Image_3D_Driver {
  4.     
  5.     protected $_filetype;
  6.  
  7.     public function __construct({
  8.         parent::__construct();
  9.         
  10.         $this->_filetype 'png';
  11.     }
  12.     
  13.     public function createImage($x$y{
  14.         $this->_image imagecreatetruecolor($x$y);
  15.     }
  16.     
  17.     protected function _getColor(Image_3D_Color $color{
  18.         $values $color->getValues();
  19.         
  20.         $values[0= (int) round($values[0* 255);
  21.         $values[1= (int) round($values[1* 255);
  22.         $values[2= (int) round($values[2* 255);
  23.         $values[3= (int) round($values[3* 127);
  24.  
  25.         if ($this->_rgbaValue[3> 0{
  26.             // Tranzparente Farbe allokieren
  27.             $color = imageColorExactAlpha($this->_image$values[0]$values[1]$values[2]$values[3]);
  28.             if ($color === -1{
  29.                 // Wenn nicht Farbe neu alloziieren
  30.                 $color = imageColorAllocateAlpha($this->_image$values[0]$values[1]$values[2]$values[3]);
  31.             }
  32.         else {
  33.             // Deckende Farbe allozieren
  34.             $color = imageColorExact($this->_image$values[0]$values[1]$values[2]);
  35.             if ($color === -1{
  36.                 // Wenn nicht Farbe neu alloziieren
  37.                 $color = imageColorAllocate($this->_image$values[0]$values[1]$values[2]);
  38.             }
  39.         }
  40.         
  41.         return $color;
  42.     }
  43.     
  44.     public function setBackground(Image_3D_Color $color{
  45.         $bg $this->_getColor($color);
  46.         imagefill($this->_image11$bg);
  47.     }
  48.     
  49.     public function drawPolygon(Image_3D_Polygon $polygon{
  50.         // Get points
  51.         $points $polygon->getPoints();
  52.         $coords = array();
  53.         foreach ($points as $point$coords array_merge($coords$point->getScreenCoordinates());
  54.         $coordCount = (int) (count($coords/ 2);
  55.         
  56.         if (true{
  57.             imageFilledPolygon($this->_image$coords$coordCount$this->_getColor($polygon->getColor()));
  58.         else {
  59.             imagePolygon($this->_image$coords$coordCount$this->_getColor($polygon->getColor()));
  60.         }
  61.         
  62.     }
  63.     
  64.     public function drawGradientPolygon(Image_3D_Polygon $polygon{
  65.         $this->drawPolygon($polygon);
  66.     }
  67.     
  68.     public function setFiletye($type{
  69.         $type strtolower($type);
  70.         if (in_array($typearray('png''jpeg'))) {
  71.             $this->_filetype $type;
  72.             return true;
  73.         else {
  74.             return false;
  75.         }
  76.     }
  77.     
  78.     public function save($file{
  79.         switch ($this->_filetype{
  80.             case 'png':
  81.                 return imagepng($this->_image$file);
  82.             case 'jpeg':
  83.                 return imagejpeg($this->_image$file);
  84.         }
  85.     }
  86.  
  87.     public function getSupportedShading({
  88.         return array(Image_3D_Renderer::SHADE_NOImage_3D_Renderer::SHADE_FLAT);
  89.     }
  90. }
  91.  
  92. ?>

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