ConvolveMatrix   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
1
<?php
2
namespace nstdio\svg\filter;
3
4
/**
5
 * Class ConvolveMatrix
6
 * feConvolveMatrix applies a matrix convolution filter effect. A convolution combines pixels in the input image with
7
 * neighboring pixels to produce a resulting image. A wide variety of imaging operations can be achieved through
8
 * convolutions, including blurring, edge detection, sharpening, embossing and beveling.
9
 *
10
 * @link    https://www.w3.org/TR/SVG11/filters.html#feConvolveMatrixElement
11
 * @property string  order            = "<number-optional-number>" Indicates the number of cells in each dimension for
12
 *           ‘kernelMatrix’. The values provided must be <integer>s greater than zero. The first number, <orderX>,
13
 *           indicates the number of columns in the matrix. The second number, <orderY>, indicates the number of rows
14
 *           in the matrix. If
15
 *           <orderY> is not provided, it defaults to <orderX>. A typical value is order="3". It is recommended that
16
 *           only small values (e.g., 3) be used; higher values may result in very high CPU overhead and usually do not
17
 *           produce results that justify the impact on performance. If the attribute is not specified, the effect is
18
 *           as if a value of 3 were specified.
19
 * @property string  kernelMatrix     = "<list of numbers>" The list of <number>s that make up the kernel matrix for
20
 *           the
21
 *           convolution. Values are separated by space characters and/or a comma. The number of entries in the list
22
 *           must equal <orderX> times <orderY>.
23
 * @property float   divisor          = "<number>" After applying the ‘kernelMatrix’ to the input image to yield a
24
 *           number, that number is divided by ‘divisor’ to yield the final destination color value. A divisor that is
25
 *           the sum of all the matrix values tends to have an evening effect on the overall color intensity of the
26
 *           result. It is an error to specify a divisor of zero. The default value is the sum of all values in
27
 *           kernelMatrix, with the exception that if the sum is zero, then the divisor is set to 1.
28
 * @property float   bias             = "<number>" After applying the ‘kernelMatrix’ to the input image to yield a
29
 *           number
30
 *           and applying the ‘divisor’, the ‘bias’ attribute is added to each component. One application of ‘bias’ is
31
 *           when it is desirable to have .5 gray value be the zero response of the filter. The bias property shifts
32
 *           the range of the filter. This allows representation of values that would otherwise be clamped to 0 or 1.
33
 *           If ‘bias’ is not specified, then the effect is as if a value of 0 were specified.
34
 * @property int     targetX          = "<integer>" Determines the positioning in X of the convolution matrix relative
35
 *           to a given target pixel in the input image. The leftmost column of the matrix is column number zero. The
36
 *           value must be such that: 0 <= targetX < orderX. By default, the convolution matrix is centered in X over
37
 *           each pixel of the input image (i.e., targetX = floor ( orderX / 2 )).
38
 * @property int     targetY          = "<integer>" Determines the positioning in Y of the convolution matrix relative
39
 *           to a given target pixel in the input image. The topmost row of the matrix is row number zero. The value
40
 *           must be such that: 0 <= targetY < orderY. By default, the convolution matrix is centered in Y over each
41
 *           pixel of the input image (i.e., targetY = floor ( orderY / 2 )).
42
 * @property string  edgeMode         = "duplicate | wrap | none" Determines how to extend the input image as necessary
43
 *           with color values so that the matrix operations can be applied when the kernel is positioned at or near
44
 *           the edge of the input image.
45
 * @property float   kernelUnitLength = "<number-optional-number>" The first number is the <dx> value. The second
46
 *           number
47
 *           is the <dy> value. If the <dy> value is not specified, it defaults to the same value as <dx>. Indicates
48
 *           the intended distance in current filter units (i.e., units as determined by the value of attribute
49
 *           ‘primitiveUnits’) between successive columns and rows, respectively, in the ‘kernelMatrix’. By specifying
50
 *           value(s) for ‘kernelUnitLength’, the kernel becomes defined in a scalable, abstract coordinate system. If
51
 *           ‘kernelUnitLength’ is not specified, the default value is one pixel in the offscreen bitmap, which is a
52
 *           pixel-based coordinate system, and thus potentially not scalable. For some level of consistency across
53
 *           display media and user agents, it is necessary that a value be provided for at least one of ‘filterRes’
54
 *           and ‘kernelUnitLength’. In some implementations, the most consistent results and the fastest performance
55
 *           will be achieved if the pixel grid of the temporary offscreen images aligns with the pixel grid of the
56
 *           kernel.
57
 * @property boolean preserveAlpha    = "false | true" A value of false indicates that the convolution will apply to
58
 *           all channels, including the alpha channel. In this case the ALPHAX,Y of the convolution formula for a
59
 *           given pixel is: A value of true indicates that the convolution will only apply to the color channels. In
60
 *           this case, the filter will temporarily unpremultiply the color component values, apply the kernel, and
61
 *           then re-premultiply at the end. In this case the ALPHAX,Y of the convolution formula for a given pixel is:
62
 *           ALPHAX,Y = SOURCEX,Y If ‘preserveAlpha’ is not specified, then the effect is as if a value of false were
63
 *           specified.
64
 * @package nstdio\svg\filter
65
 * @author  Edgar Asatryan <[email protected]>
66
 */
67
class ConvolveMatrix extends BaseFilter
68
{
69
    /**
70
     * @inheritdoc
71
     */
72 1
    public function getName()
73
    {
74 1
        return "feConvolveMatrix";
75
    }
76
77
}