Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| CrossFade | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * CSS Images 4 §4 — `cross-fade()` blends two or more images at |
| 9 | * a specified mixing percentage. The full grammar accepts a list |
| 10 | * of `<percentage>? <image>` entries (the unlabeled cross-fade |
| 11 | * sums to 100% over the unlabeled images). |
| 12 | * |
| 13 | * background: cross-fade(url(a.png), url(b.png)); |
| 14 | * background: cross-fade(25% url(a.png), 75% url(b.png)); |
| 15 | * background: cross-fade(50% url(a.png), 50% url(b.png) color(srgb 0 0 0)); |
| 16 | * |
| 17 | * Each option carries a typed Value for the image and an optional |
| 18 | * percentage `0..100`. The renderer interpolates pixel data at |
| 19 | * paint time once raster sources resolve. |
| 20 | */ |
| 21 | final readonly class CrossFade extends Value |
| 22 | { |
| 23 | /** |
| 24 | * @param list<CrossFadeOption> $options |
| 25 | */ |
| 26 | public function __construct(public array $options) {} |
| 27 | |
| 28 | public function toCss(): string |
| 29 | { |
| 30 | $parts = array_map(static fn(CrossFadeOption $o): string => $o->toCss(), $this->options); |
| 31 | return 'cross-fade(' . implode(', ', $parts) . ')'; |
| 32 | } |
| 33 | } |