4 * @link http://github.com/PhenX/php-svg-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license GNU LGPLv3+ http://www.gnu.org/copyleft/lesser.html
15 class LinearGradient
extends AbstractTag
22 /** @var Gradient\Stop[] */
23 protected $stops = array();
25 public function start($attributes)
27 parent
::start($attributes);
29 if (isset($attributes['x1'])) {
30 $this->x1
= $attributes['x1'];
32 if (isset($attributes['y1'])) {
33 $this->y1
= $attributes['y1'];
35 if (isset($attributes['x2'])) {
36 $this->x2
= $attributes['x2'];
38 if (isset($attributes['y2'])) {
39 $this->y2
= $attributes['y2'];
43 public function getStops() {
44 if (empty($this->stops
)) {
45 foreach ($this->children
as $_child) {
46 if ($_child->tagName
!= "stop") {
50 $_stop = new Gradient\
Stop();
51 $_attributes = $_child->attributes
;
54 if (isset($_attributes["style"])) {
55 $_style = Style
::parseCssStyle($_attributes["style"]);
57 if (isset($_style["stop-color"])) {
58 $_stop->color
= Style
::parseColor($_style["stop-color"]);
61 if (isset($_style["stop-opacity"])) {
62 $_stop->opacity
= max(0, min(1.0, $_style["stop-opacity"]));
67 if (isset($_attributes["offset"])) {
68 $_stop->offset
= $_attributes["offset"];
70 if (isset($_attributes["stop-color"])) {
71 $_stop->color
= Style
::parseColor($_attributes["stop-color"]);
73 if (isset($_attributes["stop-opacity"])) {
74 $_stop->opacity
= max(0, min(1.0, $_attributes["stop-opacity"]));
77 $this->stops
[] = $_stop;