push
circleci
257 of 257 new or added lines in 11 files covered. (100.0%)
696 of 1633 relevant lines covered (42.62%)
2.15 hits per line
1 |
<?php
|
|
2 |
|
|
3 |
namespace AmaTeam\Image\Projection\Image\Utility; |
|
4 |
|
|
5 |
class Color |
|
6 |
{ |
|
7 |
/**
|
|
8 |
* @param int $target |
|
9 |
* @param int $source |
|
10 |
* @return int |
|
11 |
*/ |
|
12 |
public static function blend($target, $source) |
|
|
{ |
× |
|
$targetAlpha = $target & 0xFF; |
3 only 75.1 ✔ |
|
$sourceAlpha = $source & 0xFF; |
3 only 75.1 ✔ |
|
$influence = $sourceAlpha / $targetAlpha; |
3 only 75.1 ✔ |
|
$result = ((int) ($targetAlpha + (255 - $targetAlpha) * ($sourceAlpha / 255))) & 0xFF; |
3 only 75.1 ✔ |
|
for ($i = 3; $i >= 1; $i--) { |
3 only 75.1 ✔ |
|
$shift = $i * 8; |
3 only 75.1 ✔ |
|
$targetColor = ($target >> $shift) & 0xFF; |
3 only 75.1 ✔ |
|
$sourceColor = ($source >> $shift) & 0xFF; |
3 only 75.1 ✔ |
|
$difference = $sourceColor - $targetColor; |
3 only 75.1 ✔ |
|
$color = $targetColor + $difference * $influence; |
3 only 75.1 ✔ |
|
$result |= (((int) $color) & 0xFF) << $shift; |
3 only 75.1 ✔ |
|
} |
3 only 75.1 ✔ |
|
return $result; |
3 only 75.1 ✔ |
|
} |
× |
28 |
} |