blob: 767e81dbfebe73a7a109b7d7cc5fb1cd76bc074f (
plain)
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
|
<?php
/**
* @package php-svg-lib
* @link http://github.com/PhenX/php-svg-lib
* @author Fabien Ménager <fabien.menager@gmail.com>
* @license GNU LGPLv3+ http://www.gnu.org/copyleft/lesser.html
*/
namespace Svg\Tag;
use Svg\Style;
class Shape extends AbstractTag
{
protected function before($attributes)
{
$surface = $this->document->getSurface();
$surface->save();
$style = $this->makeStyle($attributes);
$this->setStyle($style);
$surface->setStyle($style);
$this->applyTransform($attributes);
}
protected function after()
{
$surface = $this->document->getSurface();
if ($this->hasShape) {
$style = $surface->getStyle();
$fill = $style->fill && is_array($style->fill);
$stroke = $style->stroke && is_array($style->stroke);
if ($fill) {
if ($stroke) {
$surface->fillStroke(false);
} else {
// if (is_string($style->fill)) {
// /** @var LinearGradient|RadialGradient $gradient */
// $gradient = $this->getDocument()->getDef($style->fill);
//
// var_dump($gradient->getStops());
// }
$surface->fill();
}
}
elseif ($stroke) {
$surface->stroke(false);
}
else {
$surface->endPath();
}
}
$surface->restore();
}
}
|