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

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