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