Ejemplo n.º 1
0
 private function pasteImage(ImageInterface $image, ImageInterface $imageToPaste, PointInterface $pastePoint)
 {
     if (!$this->boxContains($image->getSize(), $imageToPaste->getSize(), $pastePoint)) {
         $rectangle = Rectangle::createWithSize($image->getSize())->intersection(Rectangle::create($pastePoint, $imageToPaste->getSize()));
         if ($rectangle !== null) {
             $croppingPoint = new Point($rectangle->getStartingPoint()->getX() - $pastePoint->getX(), $rectangle->getStartingPoint()->getY() - $pastePoint->getY());
             $imageToPaste->crop($croppingPoint, $rectangle->getSize());
             $image->paste($imageToPaste, $this->ensureNonNegativePoint($pastePoint));
         }
     } else {
         $image->paste($imageToPaste, $pastePoint);
     }
 }