Line.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
<?php
namespace Grafika\DrawingObject;
use Grafika\Color;
/**
* Base class
* @package Grafika
*/
abstract class Line
{
/**
* X,Y pos 1.
* @var array
*/
protected $point1;
/**
* X,Y pos 2.
* @var array
*/
protected $point2;
/**
* @var int Thickness of line.
*/
protected $thickness;
/**
* @var Color
*/
protected $color;
/**
* Creates a line.
*
* @param array $point1 Array containing int X and int Y position of the starting point.
* @param array $point2 Array containing int X and int Y position of the starting point.
* @param int $thickness Thickness in pixel. Note: This is currently ignored in GD editor and falls back to 1.
* @param Color|string $color Color of the line. Defaults to black.
*/
public function __construct(array $point1, array $point2, $thickness = 1, $color = '#000000')
{
if (is_string($color)) {
$color = new Color($color);
}
$this->point1 = $point1;
$this->point2 = $point2;
$this->thickness = $thickness;
$this->color = $color;
}
/**
* @return array
*/
public function getPoint1()
{
return $this->point1;
}
/**
* @return array
*/
public function getPoint2()
{
return $this->point2;
}
/**
* @return int
*/
public function getThickness()
{
return $this->thickness;
}
/**
* @return Color
*/
public function getColor()
{
return $this->color;
}
}