xref: /webtrees/app/Report/ReportBaseImage.php (revision ea517a3bcde172a7403de36143979b17050fb005)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Report;
21
22/**
23 * Class ReportBaseImage
24 */
25class ReportBaseImage extends ReportBaseElement
26{
27    // Filename of the image
28    public string $file;
29
30    // Height of the image
31    public float $height;
32
33    // Width of the image
34    public float $width;
35
36    // X-position (left) of the image
37    public float $x;
38
39    // Y-position (top) of the image
40    public float $y;
41
42    // Placement of the image. L: left, C:center, R:right (or empty for x/y)
43    public string $align;
44
45    // T:same line, N:next line
46    public string $line;
47
48    /**
49     * Image class function - Base
50     *
51     * @param string $file  Filename of the image
52     * @param float  $x     X-position (left) of the image
53     * @param float  $y     Y-position (top) of the image
54     * @param float  $w     Width of the image
55     * @param float  $h     Height of the image
56     * @param string $align Placement of the image. L: left, C:center, R:right
57     * @param string $ln    T:same line, N:next line
58     */
59    public function __construct(string $file, float $x, float $y, float $w, float $h, string $align, string $ln)
60    {
61        $this->file   = $file;
62        $this->width  = $w;
63        $this->height = $h;
64        $this->x      = $x;
65        $this->y      = $y;
66        $this->align  = $align;
67        $this->line   = $ln;
68    }
69
70    /**
71     * Get the height.
72     *
73     * @param HtmlRenderer|PdfRenderer $renderer
74     *
75     * @return float
76     */
77    public function getHeight($renderer): float
78    {
79        return $this->height;
80    }
81
82    /**
83     * Get the width.
84     *
85     * @param HtmlRenderer|PdfRenderer $renderer
86     *
87     * @return array{0:float,1:int,2:float}
88     */
89    public function getWidth($renderer): array
90    {
91        return [$this->width, 1, $this->height];
92    }
93}
94