|
1
|
|
|
<?php |
|
2
|
|
|
namespace nstdio\svg\gradient; |
|
3
|
|
|
|
|
4
|
|
|
use nstdio\svg\attributes\Core; |
|
5
|
|
|
use nstdio\svg\attributes\Presentation; |
|
6
|
|
|
use nstdio\svg\attributes\Styleable; |
|
7
|
|
|
use nstdio\svg\ElementInterface; |
|
8
|
|
|
use nstdio\svg\SVGElement; |
|
9
|
|
|
use nstdio\svg\traits\StyleTrait; |
|
10
|
|
|
use nstdio\svg\util\KeyValueWriter; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class Stop |
|
14
|
|
|
* |
|
15
|
|
|
* The ramp of colors to use on a gradient is defined by the 'stop' elements that are child elements to either the |
|
16
|
|
|
* 'linearGradient' element or the 'radialGradient' element. |
|
17
|
|
|
* |
|
18
|
|
|
* @link https://www.w3.org/TR/SVG11/pservers.html#GradientStops |
|
19
|
|
|
* @property string $offset "<number> | <percentage>" |
|
20
|
|
|
* The 'offset' attribute is either a <number> (usually ranging from 0 to 1) or a <percentage> (usually |
|
21
|
|
|
* ranging from 0% to 100%) which indicates where the gradient stop is placed. For linear gradients, the |
|
22
|
|
|
* 'offset' attribute represents a location along the gradient vector. For radial gradients, it represents a |
|
23
|
|
|
* percentage distance from (fx,fy) to the edge of the outermost/largest circle. |
|
24
|
|
|
* @property string $stopColor The 'stop-color' property indicates what color to use at that gradient stop. The keyword |
|
25
|
|
|
* currentColor and ICC colors can be specified in the same manner as within a <paint> specification for the |
|
26
|
|
|
* 'fill' and 'stroke' properties. |
|
27
|
|
|
* @property string $stopOpacity The 'stop-opacity' property defines the opacity of a given gradient stop. |
|
28
|
|
|
* @package nstdio\svg\gradient |
|
29
|
|
|
* @author Edgar Asatryan <[email protected]> |
|
30
|
|
|
*/ |
|
31
|
|
|
class Stop extends SVGElement implements Core, Presentation, Styleable |
|
32
|
|
|
{ |
|
33
|
|
|
use StyleTrait; |
|
34
|
|
|
|
|
35
|
38 |
|
public function __construct(ElementInterface $parent, $config = []) |
|
36
|
|
|
{ |
|
37
|
38 |
|
parent::__construct($parent); |
|
38
|
|
|
|
|
39
|
38 |
|
KeyValueWriter::apply($this->element, $config); |
|
40
|
38 |
|
} |
|
41
|
|
|
|
|
42
|
38 |
|
public function getName() |
|
43
|
|
|
{ |
|
44
|
38 |
|
return 'stop'; |
|
45
|
|
|
} |
|
46
|
|
|
} |