xref: /webtrees/app/Report/ReportBaseLine.php (revision 3cfcc809af53e831fa6cafac7b274a2cb407db6e)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
16 */
17declare(strict_types=1);
18
19namespace Fisharebest\Webtrees\Report;
20
21/**
22 * Class ReportBaseLine
23 */
24class ReportBaseLine extends ReportBaseElement
25{
26    /**
27     * Start horizontal position, current position (default)
28     *
29     * @var float
30     */
31    public $x1 = ReportBaseElement::CURRENT_POSITION;
32    /**
33     * Start vertical position, current position (default)
34     *
35     * @var float
36     */
37    public $y1 = ReportBaseElement::CURRENT_POSITION;
38    /**
39     * End horizontal position, maximum width (default)
40     *
41     * @var float
42     */
43    public $x2 = ReportBaseElement::CURRENT_POSITION;
44    /**
45     * End vertical position
46     *
47     * @var float
48     */
49    public $y2 = ReportBaseElement::CURRENT_POSITION;
50
51    /**
52     * Create a line class - Base
53     *
54     * @param mixed $x1
55     * @param mixed $y1
56     * @param mixed $x2
57     * @param mixed $y2
58     */
59    public function __construct($x1, $y1, $x2, $y2)
60    {
61        $this->x1 = $x1;
62        $this->y1 = $y1;
63        $this->x2 = $x2;
64        $this->y2 = $y2;
65    }
66
67    /**
68     * Get the height of the line.
69     *
70     * @param ReportHtml|ReportTcpdf $renderer
71     *
72     * @return float
73     */
74    public function getHeight($renderer): float
75    {
76        return abs($this->y2 - $this->y1);
77    }
78
79    /**
80     * Get the width of the line.
81     *
82     * @param ReportHtml|ReportTcpdf $renderer
83     *
84     * @return float|array
85     */
86    public function getWidth($renderer)
87    {
88        return abs($this->x2 - $this->x1);
89    }
90}
91