. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Report; /** * Class ReportHtmlImage */ class ReportHtmlImage extends ReportBaseImage { /** * Image renderer * * @param HtmlRenderer $renderer * * @return void */ public function render($renderer): void { static $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright; // Get the current positions if ($this->x === ReportBaseElement::CURRENT_POSITION) { $this->x = $renderer->getX(); } if ($this->y === ReportBaseElement::CURRENT_POSITION) { //-- first check for a collision with the last picture if ($lastpicbottom !== null && $renderer->pageNo() === $lastpicpage && $lastpicbottom >= $renderer->getY() && $this->x >= $lastpicleft && $this->x <= $lastpicright) { $renderer->setY($lastpicbottom + $renderer->cPadding * 2); } $this->y = $renderer->getY(); } // Image alignment switch ($this->align) { case 'L': echo '
\n"; echo '\"\"\n
\n"; break; case 'C': echo '
\n"; echo '\"\"\n
\n"; break; case 'R': echo '
\n"; echo '\"\"\n
\n"; break; default: echo '\"\"\n"; } $lastpicpage = $renderer->pageNo(); $lastpicleft = $this->x; $lastpicright = $this->x + $this->width; $lastpicbottom = $this->y + $this->height; // Setup for the next line if ($this->line === 'N') { $renderer->setY($lastpicbottom); } // Keep max Y updated $renderer->addMaxY($lastpicbottom); } /** * Get the image height * This would be called from the TextBox only for multiple images * so we add a bit bottom space between the images * * @param HtmlRenderer $renderer * * @return float */ public function getHeight($renderer): float { return $this->height + $renderer->cPadding * 2; } }