Exemplo n.º 1
0
 /**
  * Change the opacity of the layer
  * $recursive: apply it on sublayers.
  *
  * @param int  $opacity
  * @param bool $recursive
  */
 public function opacity($opacity, $recursive = true)
 {
     if ($recursive) {
         $layers = $this->layers;
         foreach ($layers as $key => $layer) {
             $layer->opacity($opacity, true);
             $this->layers[$key] = $layer;
         }
     }
     $transparentImage = ImageWorkshopLib::generateImage($this->getWidth(), $this->getHeight());
     ImageWorkshopLib::imageCopyMergeAlpha($transparentImage, $this->image, 0, 0, 0, 0, $this->getWidth(), $this->getHeight(), $opacity);
     unset($this->image);
     $this->image = $transparentImage;
     unset($transparentImage);
 }