PhotoMosaic: introduce availableLayouts method

This commit is contained in:
Aaron van Geffen 2023-12-01 23:41:05 +01:00
parent b98785d7b2
commit 8700fc1417

View File

@ -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;