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

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