Conditions | 1 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | 65 | public function convert(Color $color): Color |
|
15 | { |
||
16 | /* @var CMYK $color */ |
||
17 | 65 | Assert::isInstanceOf($color, CMYK::class, sprintf('color should be an instance of [%s]', CMYK::class)); |
|
18 | |||
19 | 65 | $cyan = $color->getCyan() / 100; |
|
20 | 65 | $magenta = $color->getMagenta() / 100; |
|
21 | 65 | $yellow = $color->getYellow() / 100; |
|
22 | 65 | $key = $color->getKey() / 100; |
|
23 | |||
24 | 65 | $red = 1 - min(1, $cyan * (1 - $key) + $key); |
|
25 | 65 | $green = 1 - min(1, $magenta * (1 - $key) + $key); |
|
26 | 65 | $blue = 1 - min(1, $yellow * (1 - $key) + $key); |
|
27 | |||
28 | 65 | $red *= 255; |
|
29 | 65 | $green *= 255; |
|
30 | 65 | $blue *= 255; |
|
31 | |||
32 | 65 | return new RGB((int) round($red), (int) round($green), (int) round($blue)); |
|
33 | } |
||
45 |