From 8700fc1417e4eaf0be3220be7e5720d18b8976d1 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 1 Dec 2023 23:41:05 +0100 Subject: [PATCH] PhotoMosaic: introduce availableLayouts method --- models/PhotoMosaic.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/models/PhotoMosaic.php b/models/PhotoMosaic.php index 05b2516..f4e1339 100644 --- a/models/PhotoMosaic.php +++ b/models/PhotoMosaic.php @@ -10,11 +10,13 @@ class PhotoMosaic { const NUM_DAYS_CUTOFF = 7; private AssetIterator $iterator; + private $layouts; private $queue = []; public function __construct(AssetIterator $iterator) { $this->iterator = $iterator; + $this->layouts = $this->availableLayouts(); } public function __destruct() @@ -22,6 +24,28 @@ class PhotoMosaic $this->iterator->clean(); } + private function availableLayouts() + { + static $layouts = [ + // Single panorama + 'panorama' => [Image::TYPE_PANORAMA], + + // Big-small juxtapositions + 'portrait' => [Image::TYPE_PORTRAIT, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + 'landscape' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + + // Single row of three + 'landscapes' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + 'portraits' => [Image::TYPE_PORTRAIT, Image::TYPE_PORTRAIT, Image::TYPE_PORTRAIT], + + // Fallback layouts + 'duo' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + 'single' => [Image::TYPE_LANDSCAPE | Image::TYPE_PORTRAIT], + ]; + + return $layouts; + } + private static function daysApart(Image $a, Image $b) { return $a->getDateCaptured()->diff($b->getDateCaptured())->days;