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