Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| FeFlood | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| floodColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| floodOpacity | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Svg\Filter; |
| 6 | |
| 7 | /** |
| 8 | * SVG 2 Filter Effects §15.7 — `<feFlood flood-color flood-opacity>`. |
| 9 | * Produces a solid-colour rectangle filling the primitive subregion. |
| 10 | * Together with feComposite this implements paint-source generation. |
| 11 | */ |
| 12 | final class FeFlood extends FilterPrimitive |
| 13 | { |
| 14 | public function __construct() |
| 15 | { |
| 16 | parent::__construct('feFlood'); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * `flood-color` accepts any CSS colour name / hex / rgb / etc. |
| 21 | * The raw string is returned; the consumer parses it via the |
| 22 | * shared CSS colour parser. |
| 23 | */ |
| 24 | public function floodColor(): string |
| 25 | { |
| 26 | return $this->getAttribute('flood-color') ?? 'black'; |
| 27 | } |
| 28 | |
| 29 | public function floodOpacity(): float |
| 30 | { |
| 31 | $v = $this->getAttribute('flood-opacity'); |
| 32 | if ($v === null) { |
| 33 | return 1.0; |
| 34 | } |
| 35 | return max(0.0, min(1.0, (float) $v)); |
| 36 | } |
| 37 | } |