1 | <?php |
||
36 | abstract class Shape extends SVGElement implements ShapeInterface |
||
37 | { |
||
38 | use StyleTrait, TransformTrait; |
||
39 | |||
40 | 74 | public function __construct(ElementInterface $parent) |
|
41 | { |
||
42 | 74 | parent::__construct($parent); |
|
43 | |||
44 | 74 | $this->transformImpl = Transform::newInstance($this->getTransformAttribute()); |
|
45 | 74 | } |
|
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | */ |
||
50 | 74 | public function getTransformAttribute() |
|
51 | { |
||
52 | 74 | return $this->transform; |
|
53 | } |
||
54 | |||
55 | abstract public function getBoundingBox(); |
||
56 | |||
57 | 1 | public function setTransformAttribute($transformList) |
|
58 | { |
||
59 | 1 | $this->transform = $transformList; |
|
60 | |||
61 | 1 | return $this; |
|
62 | } |
||
63 | |||
64 | 1 | public function animate(BaseAnimation $animation) |
|
65 | { |
||
66 | 1 | $this->element->appendChild($animation->getElement()); |
|
|
|||
67 | |||
68 | 1 | return $this; |
|
69 | } |
||
70 | |||
71 | 2 | public function filterGaussianBlur($stdDeviation, $in = null, $filterId = null) |
|
72 | { |
||
73 | 2 | $filter = new Filter($this->getRoot(), $filterId); |
|
74 | 2 | $blur = new GaussianBlur($filter); |
|
75 | 2 | $blur->stdDeviation = $stdDeviation; |
|
76 | 2 | $blur->in = $in; |
|
77 | |||
78 | 2 | $this->applyFilter($filter); |
|
79 | |||
80 | 2 | return $this; |
|
81 | } |
||
82 | |||
83 | 3 | public function applyFilter(BaseFilter $filter) |
|
84 | { |
||
85 | 3 | $svg = $this->getSVG(); |
|
86 | 3 | if ($this->filter === null) { |
|
87 | 3 | $this->filterUrl = $filter->id; |
|
88 | 3 | $defs = $svg->getFirstChild(); |
|
89 | 3 | $filter->selfRemove(); |
|
90 | 3 | $defs->append($filter); |
|
91 | 3 | } else { |
|
92 | 1 | $currentFilter = $svg->getFirstChild()->getChildById($this->filterUrl); |
|
93 | 1 | if ($currentFilter !== null) { |
|
94 | 1 | foreach ($filter->getChildren() as $child) { |
|
95 | 1 | $currentFilter->append($child); |
|
96 | 1 | } |
|
97 | 1 | $filter->selfRemove(); |
|
98 | 1 | } |
|
99 | } |
||
100 | |||
101 | 3 | return $this; |
|
102 | } |
||
103 | |||
104 | 1 | public function diffusePointLight(array $pointLightConfig = [], array $diffuseLightingConfig = [], $filterId = null) |
|
105 | { |
||
106 | $pointConfig = [ |
||
107 | 1 | 'x' => $this->getCenterX(), |
|
108 | 1 | 'y' => $this->getCenterY(), |
|
109 | 1 | 'z' => 25, |
|
110 | 1 | ]; |
|
111 | 1 | foreach ($pointConfig as $key => $value) { |
|
112 | 1 | if (isset($pointLightConfig[$key])) { |
|
113 | 1 | $pointConfig[$key] = $value + $pointLightConfig[$key]; |
|
114 | 1 | } |
|
115 | 1 | } |
|
116 | 1 | $filter = DiffuseLighting::diffusePointLight($this->getRoot(), $pointConfig, $diffuseLightingConfig, $filterId); |
|
117 | 1 | $this->applyFilter($filter); |
|
118 | |||
119 | 1 | return $this; |
|
120 | } |
||
121 | |||
122 | abstract protected function getCenterX(); |
||
123 | |||
124 | abstract protected function getCenterY(); |
||
125 | |||
126 | 1 | public function linearGradientFromTop(array $colors, $id = null) |
|
127 | { |
||
128 | 1 | return $this->applyGradient(UniformGradient::verticalFromTop($this->getRoot(), $colors, $id)); |
|
129 | } |
||
130 | |||
131 | 17 | public function applyGradient(Gradient $gradient) |
|
132 | { |
||
133 | 17 | $this->fillUrl = $gradient->id; |
|
137 | |||
138 | 1 | public function linearGradientFromBottom(array $colors, $id = null) |
|
142 | |||
143 | 1 | public function linearGradientFromLeft(array $colors, $id = null) |
|
147 | |||
148 | 1 | public function linearGradientFromRight(array $colors, $id = null) |
|
152 | |||
153 | 1 | public function linearGradientFromTopLeft(array $colors, $id = null) |
|
157 | |||
158 | 1 | public function linearGradientFromTopRight(array $colors, $id = null) |
|
162 | |||
163 | 1 | public function linearGradientFromBottomLeft(array $colors, $id = null) |
|
167 | |||
168 | 1 | public function linearGradientFromBottomRight(array $colors, $id = null) |
|
172 | |||
173 | 1 | public function radialGradientFromTopLeft(array $colors, $id = null) |
|
177 | |||
178 | 1 | public function radialGradientFromTopRight(array $colors, $id = null) |
|
182 | |||
183 | 1 | public function radialGradientFromBottomLeft(array $colors, $id = null) |
|
187 | |||
188 | 1 | public function radialGradientFromBottomRight(array $colors, $id = null) |
|
192 | |||
193 | 1 | public function radialGradientFromTopCenter(array $colors, $id = null) |
|
197 | |||
198 | 1 | public function radialGradientFromLeftCenter(array $colors, $id = null) |
|
202 | |||
203 | 1 | public function radialGradientFromBottomCenter(array $colors, $id = null) |
|
207 | |||
208 | 1 | public function radialGradientFromRightCenter(array $colors, $id = null) |
|
212 | } |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.