Passed
Push — dev ( e9cf15...64faf7 )
by Fike
03:26
created

EdgeOrientationCalculator::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AmaTeam\Image\Projection\Conversion\Processor\FXAA;
4
5
class EdgeOrientationCalculator
6
{
7
    public static function apply(Edge $edge)
8
    {
9
        $grid = $edge->luma;
10
        $vertical =
11
            abs(($grid->northWest / 4) - ($grid->north / 2) + ($grid->northEast / 4)) +
12
            abs(($grid->west / 2) - $grid->center + ($grid->east / 2)) +
13
            abs(($grid->southWest) / 4) - ($grid->south / 2) + ($grid->southEast / 4);
14
        $horizontal =
15
            abs(($grid->northWest / 4) - ($grid->west / 2) + ($grid->southWest / 4)) +
16
            abs(($grid->north / 2) - $grid->center + ($grid->south / 2)) +
17
            abs(($grid->northEast / 4) - ($grid->east / 2) + ($grid->southEast / 4));
18
        $edge->horizontal = $horizontal >= $vertical;
19
    }
20
}
21