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

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