Polygon.php
2.2 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
namespace Grafika\DrawingObject;
use Grafika\Color;
/**
* Base class
* @package Grafika
*/
abstract class Polygon
{
/**
* Image width in pixels
* @var int
*/
protected $width;
/**
* Image height in pixels
* @var int
*/
protected $height;
/**
* Array of all X and Y positions. Must have at least three positions (x,y).
* @var array
*/
protected $points;
/**
* @var int
*/
protected $borderSize;
/**
* @var Color
*/
protected $fillColor;
/**
* @var Color
*/
protected $borderColor;
/**
* Creates a polygon.
*
* @param array $points Array of all X and Y positions. Must have at least three positions.
* @param int $borderSize Size of the border in pixels. Defaults to 1 pixel. Set to 0 for no border.
* @param Color|string|bool $borderColor Border color. Defaults to black. Set to null for no color.
* @param Color|string|bool $fillColor Fill color. Defaults to white. Set to null for no color.
*/
public function __construct($points = array(array(0,0), array(0,0), array(0,0)), $borderSize = 1, $borderColor = '#000000', $fillColor = '#FFFFFF') {
if (is_string($borderColor)) {
$borderColor = new Color($borderColor);
}
if (is_string($fillColor)) {
$fillColor = new Color($fillColor);
}
$this->points = $points;
$this->borderSize = $borderSize;
$this->borderColor = $borderColor;
$this->fillColor = $fillColor;
}
/**
* @return int
*/
public function getWidth()
{
return $this->width;
}
/**
* @return int
*/
public function getHeight()
{
return $this->height;
}
/**
* @return array
*/
public function getPoints()
{
return $this->points;
}
/**
* @return int
*/
public function getBorderSize()
{
return $this->borderSize;
}
/**
* @return Color
*/
public function getFillColor()
{
return $this->fillColor;
}
/**
* @return Color
*/
public function getBorderColor()
{
return $this->borderColor;
}
}