|
1
|
|
|
<?php |
|
2
|
|
|
namespace nstdio\svg\filter; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Class DisplacementMap |
|
6
|
|
|
* This filter primitive uses the pixels values from the image from ‘in2’ to spatially displace the image from ‘in’. |
|
7
|
|
|
* This is the transformation to be performed: |
|
8
|
|
|
* |
|
9
|
|
|
* P'(x,y) <- P( x + scale * (XC(x,y) - .5), y + scale * (YC(x,y) - .5)) |
|
10
|
|
|
* |
|
11
|
|
|
* where P(x,y) is the input image, ‘in’, and P'(x,y) is the destination. XC(x,y) and YC(x,y) are the component values |
|
12
|
|
|
* of the channel designated by the xChannelSelector and yChannelSelector. For example, to use the R component of ‘in2’ |
|
13
|
|
|
* to control displacement in x and the G component of Image2 to control displacement in y, set xChannelSelector to "R" |
|
14
|
|
|
* and yChannelSelector to "G". |
|
15
|
|
|
* |
|
16
|
|
|
* @link https://www.w3.org/TR/SVG11/filters.html#feDisplacementMapElement |
|
17
|
|
|
* @property float scale = "<number>" Displacement scale factor. The amount is expressed in the coordinate |
|
18
|
|
|
* system established by attribute ‘primitiveUnits’ on the ‘filter’ element. When the value of this attribute |
|
19
|
|
|
* is 0, this operation has no effect on the source image. If the attribute is not specified, then the effect |
|
20
|
|
|
* is as if a value of 0 were specified. |
|
21
|
|
|
* @property float xChannelSelector = "R | G | B | A" Indicates which channel from ‘in2’ to use to displace the pixels |
|
22
|
|
|
* in ‘in’ along the x-axis. If attribute ‘xChannelSelector’ is not specified, then the effect is as if a |
|
23
|
|
|
* value of A were specified. |
|
24
|
|
|
* @property float yChannelSelector = "R | G | B | A" Indicates which channel from ‘in2’ to use to displace the pixels |
|
25
|
|
|
* in ‘in’ along the y-axis. If attribute ‘yChannelSelector’ is not specified, then the effect is as if a |
|
26
|
|
|
* value of A were specified. |
|
27
|
|
|
* @property string in2 = "(see ‘in’ attribute)" The second input image, which is used to displace the |
|
28
|
|
|
* pixels in the image from attribute ‘in’. This attribute can take on the same values as the ‘in’ attribute. |
|
29
|
|
|
* @package nstdio\svg\filter |
|
30
|
|
|
* @author Edgar Asatryan <[email protected]> |
|
31
|
|
|
*/ |
|
32
|
|
|
class DisplacementMap extends BaseFilter |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @inheritdoc |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function getName() |
|
38
|
|
|
{ |
|
39
|
1 |
|
return "feDisplacementMap"; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
} |