Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
84.62% |
11 / 13 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ThreeDNode | |
84.62% |
11 / 13 |
|
50.00% |
1 / 2 |
6.13 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
83.33% |
10 / 12 |
|
0.00% |
0 / 1 |
5.12 | |||
| 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\PdfBoolean; |
| 9 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 10 | use Phpdftk\Pdf\Core\PdfName; |
| 11 | use Phpdftk\Pdf\Core\PdfObject; |
| 12 | use Phpdftk\Pdf\Core\PdfString; |
| 13 | use Phpdftk\Pdf\Core\PdfVersion; |
| 14 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 15 | |
| 16 | /** |
| 17 | * 3D node dictionary (/Type /3DNode) — ISO 32000-2 §13.6.4.5. |
| 18 | * |
| 19 | * Overrides the transform / visibility / rendering of a named node |
| 20 | * inside a 3D stream. Referenced from `ThreeDView::$na`. |
| 21 | */ |
| 22 | #[RequiresPdfVersion(PdfVersion::V1_6)] |
| 23 | class ThreeDNode extends PdfObject |
| 24 | { |
| 25 | public const PDF_TYPE = '3DNode'; |
| 26 | |
| 27 | public PdfString $n; // /N - name (required) |
| 28 | public ?PdfArray $m = null; // /M - transform matrix |
| 29 | public ?bool $v = null; // /V - visible |
| 30 | public ?float $o = null; // /O - opacity |
| 31 | public ?PdfDictionary $rm = null; // /RM - render mode override |
| 32 | |
| 33 | public function __construct(string $name) |
| 34 | { |
| 35 | $this->n = new PdfString($name); |
| 36 | } |
| 37 | |
| 38 | public function toPdf(): string |
| 39 | { |
| 40 | $dict = new PdfDictionary(); |
| 41 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 42 | $dict->set('N', $this->n); |
| 43 | if ($this->m !== null) { |
| 44 | $dict->set('M', $this->m); |
| 45 | } |
| 46 | if ($this->v !== null) { |
| 47 | $dict->set('V', new PdfBoolean($this->v)); |
| 48 | } |
| 49 | if ($this->o !== null) { |
| 50 | $dict->set('O', new \Phpdftk\Pdf\Core\PdfNumber($this->o)); |
| 51 | } |
| 52 | if ($this->rm !== null) { |
| 53 | $dict->set('RM', $this->rm); |
| 54 | } |
| 55 | return $dict->toPdf(); |
| 56 | } |
| 57 | } |