Exemplo n.º 1
0
 /**
  * Index a sublayer in the layer stack
  * Return an array containing the generated sublayer id and its final level:
  * array("layerLevel" => integer, "id" => integer).
  *
  * @param int                $layerLevel
  * @param ImageWorkshopLayer $layer
  * @param int                $positionX
  * @param int                $positionY
  * @param string             $position
  *
  * @return array
  */
 protected function indexLayer($layerLevel, $layer, $positionX, $positionY, $position)
 {
     // Choose an id for the added layer
     $layerId = $this->lastLayerId + 1;
     // Clone $layer to duplicate image resource var
     $layer = clone $layer;
     // Add the layer in the stack
     $this->layers[$layerId] = $layer;
     // Add the layer positions in the main layer
     $this->layerPositions[$layerId] = ImageWorkshopLib::calculatePositions($this->getWidth(), $this->getHeight(), $layer->getWidth(), $layer->getHeight(), $positionX, $positionY, $position);
     // Update the lastLayerId of the workshop
     $this->lastLayerId = $layerId;
     // Add the layer level in the stack
     $layerLevel = $this->indexLevelInDocument($layerLevel, $layerId);
     return array('layerLevel' => $layerLevel, 'id' => $layerId);
 }