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

Source for file ImageMagick.php

Documentation is available at ImageMagick.php

  1. <?php
  2.  
  3. {
  4.     
  5.     /**
  6.      * Array of parameter strings passed to 'convert' binary.
  7.      * 
  8.      * @var array 
  9.      * @access protected
  10.      */
  11.     protected $_commandQueue = array();
  12.  
  13.     public function __construct()
  14.     {
  15.         parent::__construct();
  16.     }
  17.     
  18.     public function createImage($x$y)
  19.     {
  20.         $this->_image = tempnam();
  21.  
  22.         $this->_dimensions = array('x' => $x'y' => $y);
  23.  
  24.         $this->_commandQueue[= "-size {$x}x{$y} xc:transparent";
  25.     }
  26.     
  27.     protected function _getColor(Image_3D_Color $color)
  28.     {
  29.         $values $color->getValues();
  30.  
  31.         $values[0= (int) round($values[0* 255);
  32.         $values[1= (int) round($values[1* 255);
  33.         $values[2= (int) round($values[2* 255);
  34.         $values[3= (int) round($values[3* 127);
  35.         
  36.         $color '';
  37.         if ($values[3> 0{
  38.             $color 'rgba('.implode(','$values).')';
  39.         else {
  40.             unset($values[3]);
  41.             $color 'rgb('.implode(','$values).')';
  42.         }
  43.         
  44.         return $color;
  45.     }
  46.     
  47.     public function setBackground(Image_3D_Color $color)
  48.     {
  49.         $colorString $this->_getColor($color);
  50.         array_splice($this->_commandQueue
  51.                      1
  52.                      0
  53.                      '-fill '.escapeshellarg($colorString).' '.
  54.                      '-draw '.escapeshellarg('rectangle 0,0 '.implode(','$this->_dimensions)));
  55.     }
  56.     
  57.     public function drawPolygon(Image_3D_Polygon $polygon)
  58.     {
  59.         // Get points
  60.         $points $polygon->getPoints();
  61.         $coords = array();
  62.  
  63.         $coords '';
  64.         foreach ($points as $point{
  65.             $pointCoords $point->getScreenCoordinates();
  66.  
  67.             $coords .= (int)$pointCoords[0].','.(int)$pointCoords[1].' ';
  68.         }
  69.         
  70.         $command  '-fill '.escapeshellarg($this->_getColor($polygon->getColor()));
  71.         $command .= ' -draw '.escapeshellarg('polygon '.trim($coords));
  72.  
  73.         $this->_commandQueue[$command;
  74.     }
  75.     
  76.     public function drawGradientPolygon(Image_3D_Polygon $polygon)
  77.     {
  78.         $this->drawPolygon($polygon);
  79.     }
  80.     
  81.     public function setFiletye($type)
  82.     {
  83.         $type strtolower($type);
  84.         if (in_array($typearray('png''jpeg'))) {
  85.             $this->_filetype $type;
  86.             return true;
  87.         else {
  88.             return false;
  89.         }
  90.     }
  91.     
  92.     public function save($file)
  93.     {
  94.         $command      '';
  95.         $commandCount = 1;
  96.         $firstRun     = true;
  97.  
  98.         for ($i = 0; $i count($this->_commandQueue)$i++{
  99.             $command .= ' '.$this->_commandQueue[$i].' ';
  100.             if (strlen($command> 1000 || $i == count($this->_commandQueue- 1{
  101.                 $firstRun === false ? $command $file ' ' $command $firstRun = false;
  102.                 
  103.                 $command =  'convert ' $command ' ' $file;
  104.                 // echo "Excuting command run <".$commandCount++.">\n";
  105.                 shell_exec($command);
  106.                 $command '';
  107.             }
  108.         }
  109.         shell_exec($command);
  110.     }
  111.  
  112.     public function getSupportedShading()
  113.     {
  114.         return array(Image_3D_Renderer::SHADE_NOImage_3D_Renderer::SHADE_FLAT);
  115.     }
  116. }
  117.  
  118. ?>

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