Curve.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. declare(strict_types = 1);
  3. namespace BaconQrCode\Renderer\Path;
  4. final class Curve implements OperationInterface
  5. {
  6. /**
  7. * @var float
  8. */
  9. private $x1;
  10. /**
  11. * @var float
  12. */
  13. private $y1;
  14. /**
  15. * @var float
  16. */
  17. private $x2;
  18. /**
  19. * @var float
  20. */
  21. private $y2;
  22. /**
  23. * @var float
  24. */
  25. private $x3;
  26. /**
  27. * @var float
  28. */
  29. private $y3;
  30. public function __construct(float $x1, float $y1, float $x2, float $y2, float $x3, float $y3)
  31. {
  32. $this->x1 = $x1;
  33. $this->y1 = $y1;
  34. $this->x2 = $x2;
  35. $this->y2 = $y2;
  36. $this->x3 = $x3;
  37. $this->y3 = $y3;
  38. }
  39. public function getX1() : float
  40. {
  41. return $this->x1;
  42. }
  43. public function getY1() : float
  44. {
  45. return $this->y1;
  46. }
  47. public function getX2() : float
  48. {
  49. return $this->x2;
  50. }
  51. public function getY2() : float
  52. {
  53. return $this->y2;
  54. }
  55. public function getX3() : float
  56. {
  57. return $this->x3;
  58. }
  59. public function getY3() : float
  60. {
  61. return $this->y3;
  62. }
  63. /**
  64. * @return self
  65. */
  66. public function translate(float $x, float $y) : OperationInterface
  67. {
  68. return new self(
  69. $this->x1 + $x,
  70. $this->y1 + $y,
  71. $this->x2 + $x,
  72. $this->y2 + $y,
  73. $this->x3 + $x,
  74. $this->y3 + $y
  75. );
  76. }
  77. }