Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
12 | public static function blend($target, $source) |
||
13 | { |
||
14 | $targetAlpha = $target & 0xFF; |
||
15 | $sourceAlpha = $source & 0xFF; |
||
16 | $influence = $sourceAlpha / $targetAlpha; |
||
17 | $result = ((int) ($targetAlpha + (255 - $targetAlpha) * ($sourceAlpha / 255))) & 0xFF; |
||
18 | for ($i = 3; $i >= 1; $i--) { |
||
19 | $shift = $i * 8; |
||
20 | $targetColor = ($target >> $shift) & 0xFF; |
||
21 | $sourceColor = ($source >> $shift) & 0xFF; |
||
22 | $difference = $sourceColor - $targetColor; |
||
23 | $color = $targetColor + $difference * $influence; |
||
24 | $result |= (((int) $color) & 0xFF) << $shift; |
||
25 | } |
||
26 | return $result; |
||
27 | } |
||
29 |