CubicBezier.php 2.0 KB

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