<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\Utils\Pdf\Helper;

use Kufer\Web\Classes\Pdf\ExtFPDITcPDF;


class Line extends RenderObject
{
  protected $x0;
  protected $y0;
  protected $x1;
  protected $y1;

  
  public function __construct($fpdf, $x0, $y0, $x1, $y1)
  {
    parent::__construct($fpdf);
    $this->setXY0($x0, $y0);
    $this->setXY1($x1, $y1);
  }

  
  public function setXY0($x0, $y0): void
  {
    $this->x0 = $x0;
    $this->y0 = $y0;
  }

  
  public function setXY1($x1, $y1): void
  {
    $this->x1 = $x1;
    $this->y1 = $y1;
  }

  public function getX0()
  {
    return $this->x0;
  }

  public function getY0()
  {
    return $this->y0;
  }

  public function getXY0()
  {
    return array($this->x0, $this->y0);
  }

  public function getX1()
  {
    return $this->x1;
  }

  public function getY1()
  {
    return $this->y1;
  }

  public function getXY1()
  {
    return array($this->x1, $this->y1);
  }

  public function render(): void
  {
    $this->context(function() {
      $this->fpdf->Line(
        $this->fpdf->getWidthAbsolute($this->x0),
        $this->fpdf->getHeightAbsolute($this->y0),
        $this->fpdf->getWidthAbsolute($this->x1),
        $this->fpdf->getHeightAbsolute($this->y1)
      );
    });
  }
}