public function generatePool($color, $darken, $hue = 180, $saturation = 0) { set_time_limit(0); $cacheKey = "c{$color}d{$darken}h{$hue}s{$saturation}"; $poolCache = new \poolCaching($cacheKey); if ($poolCache->is_cached()) { $poolImageCached = $poolCache->read_cache(); return $poolImageCached; } else { $wall = $this->wall->generatePoolWall($color, $darken, $hue, $saturation); $shadowMask = $this->applyShadow($wall); $wall->compositeimage($shadowMask, Imagick::COMPOSITE_MULTIPLY, 0, 0); $structure = new \poolStructure($color); $structureImage = $structure->generateStructure(); $wall->compositeimage($structureImage, Imagick::COMPOSITE_DEFAULT, 0, 0); $poolImage = base64_encode($wall->getImageBlob()); $poolCache->write_cache($poolImage); return $poolImage; } }
public function generateStructure() { $cacheKey = "ps{$this->color}"; $structureCache = new \poolCaching($cacheKey, '.png'); if ($structureCache->is_cached()) { $structure = new Imagick($structureCache->getCacheFile()); return $structure; } else { $structure = $this->buildBase(); $structureUpright = $this->applyUprightsMask(); if ($structureUpright) { $structure->compositeimage($structureUpright, Imagick::COMPOSITE_DEFAULT, 0, 0); $structureUpright->clear(); } $structureCover = $this->applyCoverMask(); if ($structureCover) { $structure->compositeimage($structureCover, Imagick::COMPOSITE_DEFAULT, 0, 0); $structureCover->clear(); } $structureLedge = $this->applyLedgeMask(); if ($structureLedge) { $structure->compositeimage($structureLedge, Imagick::COMPOSITE_DEFAULT, 0, 0); $structureLedge->clear(); } $structureFoot = $this->applyFootMask(); if ($structureFoot) { $structure->compositeimage($structureFoot, Imagick::COMPOSITE_DEFAULT, 0, 0); $structureFoot->clear(); } $structureRails = $this->applyRailsMask(); if ($structureRails) { $structure->compositeimage($structureRails, Imagick::COMPOSITE_DEFAULT, 0, 0); $structureRails->clear(); } $structure->setformat('PNG'); $structureImage = $structure->getImageBlob(); $structureCache->write_cache($structureImage); return $structure; } }