xref: /webtrees/app/Report/ReportBaseLine.php (revision 0115bc1678cafd957052cd2d256563ad3e242cc1)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Report;
19
20/**
21 * Class ReportBaseLine
22 */
23class ReportBaseLine extends ReportBaseElement
24{
25    /**
26     * Start horizontal position, current position (default)
27     *
28     * @var float
29     */
30    public $x1 = ReportBaseElement::CURRENT_POSITION;
31    /**
32     * Start vertical position, current position (default)
33     *
34     * @var float
35     */
36    public $y1 = ReportBaseElement::CURRENT_POSITION;
37    /**
38     * End horizontal position, maximum width (default)
39     *
40     * @var float
41     */
42    public $x2 = ReportBaseElement::CURRENT_POSITION;
43    /**
44     * End vertical position
45     *
46     * @var float
47     */
48    public $y2 = ReportBaseElement::CURRENT_POSITION;
49
50    /**
51     * Create a line class - Base
52     *
53     * @param mixed $x1
54     * @param mixed $y1
55     * @param mixed $x2
56     * @param mixed $y2
57     */
58    public function __construct($x1, $y1, $x2, $y2)
59    {
60        $this->x1 = $x1;
61        $this->y1 = $y1;
62        $this->x2 = $x2;
63        $this->y2 = $y2;
64    }
65
66    /**
67     * Get the height of the line.
68     *
69     * @param ReportHtml|ReportTcpdf $renderer
70     *
71     * @return float
72     */
73    public function getHeight($renderer): float
74    {
75        return abs($this->y2 - $this->y1);
76    }
77
78    /**
79     * Get the width of the line.
80     *
81     * @param ReportHtml|ReportTcpdf $renderer
82     *
83     * @return float|array
84     */
85    public function getWidth($renderer)
86    {
87        return abs($this->x2 - $this->x1);
88    }
89}
90