/
Gradient.php
executable file
·196 lines (175 loc) · 3.84 KB
/
Gradient.php
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php namespace Khill\Lavacharts\Configs;
/**
* Gradient Object
*
* An object that specifies a color gradient
*
*
* @package Lavacharts
* @subpackage Configs
* @author Kevin Hill <kevinkhill@gmail.com>
* @copyright (c) 2015, KHill Designs
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
use Khill\Lavacharts\Exceptions\InvalidConfigValue;
class Gradient extends ConfigObject
{
/**
* Start color for gradient.
*
* @var int
*/
public $color1;
/**
* Finish color for gradient.
*
* @var int
*/
public $color2;
/**
* Where on the boundary to start in X.
*
* @var array
*/
public $x1;
/**
* Where on the boundary to start in Y.
*
* @var array
*/
public $y1;
/**
* Where on the boundary to finish, relative to $x1.
*
* @var array
*/
public $x2;
/**
* Where on the boundary to finish, relative to $y1.
*
* @var array
*/
public $y2;
/**
* Builds the gradient object with specified options
*
* @param array $config
* @throws InvalidConfigValue
* @throws InvalidConfigProperty
* @return Gradient
*/
public function __construct($config = array())
{
parent::__construct($this, $config);
}
/**
* If present, specifies the start color for the gradient.
*
* @param string $color1
* @return Gradient
*/
public function color1($color1)
{
if (is_string($color1)) {
$this->color1 = $color1;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string'
);
}
return $this;
}
/**
* If present, specifies the finish color for the gradient.
*
* @param string $color2
* @return Gradient
*/
public function color2($color2)
{
if (is_string($color2)) {
$this->color2 = $color2;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string'
);
}
return $this;
}
/**
* Sets where on the boundary to start in X.
*
* @param string $x1
* @return Gradient
*/
public function x1($x1)
{
if (is_string($x1)) {
$this->x1 = $x1;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string'
);
}
return $this;
}
/**
* Sets where on the boundary to start in Y.
*
* @param string $y1
* @return Gradient
*/
public function y1($y1)
{
if (is_string($y1)) {
$this->y1 = $y1;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string'
);
}
return $this;
}
/**
* Sets where on the boundary to end in X, relative to x1.
*
* @param string $x2
* @return Gradient
*/
public function x2($x2)
{
if (is_string($x2)) {
$this->x2 = $x2;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string'
);
}
return $this;
}
/**
* Sets where on the boundary to end in Y, relative to y1.
*
* @param string $y2
* @return Gradient
*/
public function y2($y2)
{
if (is_string($y2)) {
$this->y2 = $y2;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string'
);
}
return $this;
}
}