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