Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ThreeDRenderMode | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
6 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\ThreeD; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfNumber; |
| 11 | use Phpdftk\Pdf\Core\PdfObject; |
| 12 | use Phpdftk\Pdf\Core\PdfVersion; |
| 13 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 14 | |
| 15 | /** |
| 16 | * 3D render mode dictionary (/Type /3DRenderMode) — ISO 32000-2 §13.6.6. |
| 17 | */ |
| 18 | #[RequiresPdfVersion(PdfVersion::V1_6)] |
| 19 | class ThreeDRenderMode extends PdfObject |
| 20 | { |
| 21 | public const PDF_TYPE = '3DRenderMode'; |
| 22 | |
| 23 | public PdfName $subtype; // /Subtype - required render mode |
| 24 | public ?PdfArray $ac = null; // /AC auxiliary color |
| 25 | public ?PdfArray $fc = null; // /FC face color |
| 26 | public ?float $op = null; // /OP opacity |
| 27 | public ?bool $cv = null; // /CV crease value |
| 28 | |
| 29 | public function __construct(string $subtype) |
| 30 | { |
| 31 | $this->subtype = new PdfName($subtype); |
| 32 | } |
| 33 | |
| 34 | public function toPdf(): string |
| 35 | { |
| 36 | $dict = new PdfDictionary(); |
| 37 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 38 | $dict->set('Subtype', $this->subtype); |
| 39 | if ($this->ac !== null) { |
| 40 | $dict->set('AC', $this->ac); |
| 41 | } |
| 42 | if ($this->fc !== null) { |
| 43 | $dict->set('FC', $this->fc); |
| 44 | } |
| 45 | if ($this->op !== null) { |
| 46 | $dict->set('Opacity', new PdfNumber($this->op)); |
| 47 | } |
| 48 | if ($this->cv !== null) { |
| 49 | $dict->set('CV', new \Phpdftk\Pdf\Core\PdfBoolean($this->cv)); |
| 50 | } |
| 51 | return $dict->toPdf(); |
| 52 | } |
| 53 | } |