QuadraticBezier.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Grafika\DrawingObject;
  3. use Grafika\Color;
  4. /**
  5. * Base class
  6. * @package Grafika
  7. */
  8. abstract class QuadraticBezier
  9. {
  10. /**
  11. * Starting point.
  12. * @var array
  13. */
  14. protected $point1;
  15. /**
  16. * Control point.
  17. * @var array
  18. */
  19. protected $control;
  20. /**
  21. * End point.
  22. * @var array
  23. */
  24. protected $point2;
  25. /**
  26. * Color of curve.
  27. *
  28. * @var Color
  29. */
  30. protected $color;
  31. /**
  32. * Creates a quadratic bezier. Quadratic bezier has 1 control point.
  33. *
  34. * @param array $point1 Array of X and Y value for start point.
  35. * @param array $control Array of X and Y value for control point.
  36. * @param array $point2 Array of X and Y value for end point.
  37. * @param Color|string $color Color of the curve. Accepts hex string or a Color object. Defaults to black.
  38. */
  39. public function __construct($point1, $control, $point2, $color = '#000000')
  40. {
  41. if (is_string($color)) {
  42. $color = new Color($color);
  43. }
  44. $this->point1 = $point1;
  45. $this->control = $control;
  46. $this->point2 = $point2;
  47. $this->color = $color;
  48. }
  49. /**
  50. * @return array
  51. */
  52. public function getPoint1()
  53. {
  54. return $this->point1;
  55. }
  56. /**
  57. * @return array
  58. */
  59. public function getControl()
  60. {
  61. return $this->control;
  62. }
  63. /**
  64. * @return array
  65. */
  66. public function getPoint2()
  67. {
  68. return $this->point2;
  69. }
  70. /**
  71. * @return Color
  72. */
  73. public function getColor()
  74. {
  75. return $this->color;
  76. }
  77. }