|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jul 7, 2016 - 1:01:57 AM |
|
5
|
|
|
* Contact [email protected] |
|
6
|
|
|
* @copyright 2016 Marko Kungla - https://github.com/mkungla |
|
7
|
|
|
* @license The MIT License (MIT) |
|
8
|
|
|
* |
|
9
|
|
|
* @category AframeVR |
|
10
|
|
|
* @package aframe-php |
|
11
|
|
|
* |
|
12
|
|
|
* Lang PHP (php version >= 7) |
|
13
|
|
|
* Encoding UTF-8 |
|
14
|
|
|
* File CanvasComponent.php |
|
15
|
|
|
* Code format PSR-2 and 12 |
|
16
|
|
|
* @link https://github.com/mkungla/aframe-php |
|
17
|
|
|
* @issues https://github.com/mkungla/aframe-php/issues |
|
18
|
|
|
* ******************************************************************** |
|
19
|
|
|
* Contributors: |
|
20
|
|
|
* @author Marko Kungla <[email protected]> |
|
21
|
|
|
* ******************************************************************** |
|
22
|
|
|
* Comments: |
|
23
|
|
|
* @formatter:on */ |
|
24
|
|
|
namespace AframeVR\Core\Components\ascene\Canvas; |
|
25
|
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Core\Components\ascene\CanvasCMPTIF; |
|
27
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
|
28
|
|
|
|
|
29
|
|
|
class CanvasComponent extends ComponentAbstract implements CanvasCMPTIF |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Initialize Component |
|
34
|
|
|
* |
|
35
|
|
|
* {@inheritdoc} |
|
36
|
|
|
* |
|
37
|
|
|
* @return bool |
|
38
|
|
|
*/ |
|
39
|
1 |
|
public function initializeComponent(): bool |
|
40
|
|
|
{ |
|
41
|
1 |
|
$this->setDomAttribute('canvas'); |
|
42
|
1 |
|
$this->height(); |
|
43
|
1 |
|
$this->width(); |
|
44
|
1 |
|
return true; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Canvas Selector |
|
49
|
|
|
* |
|
50
|
|
|
* Selector to a canvas element that exists on the page. |
|
51
|
|
|
* |
|
52
|
|
|
* @param null|string $active |
|
53
|
|
|
* @return CanvasCMPTIF |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function canvas(string $active = null): CanvasCMPTIF |
|
56
|
|
|
{ |
|
57
|
1 |
|
$this->dom_attributes['canvas'] = $active; |
|
58
|
1 |
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Canvas height |
|
63
|
|
|
* |
|
64
|
|
|
* Height of the injected canvas, in percentage. |
|
65
|
|
|
* |
|
66
|
|
|
* @param int|float $height |
|
67
|
|
|
* @return CanvasCMPTIF |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public function height(float $height = 100): CanvasCMPTIF |
|
70
|
|
|
{ |
|
71
|
1 |
|
$this->dom_attributes['height'] = $height; |
|
72
|
1 |
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Canvas width |
|
77
|
|
|
* |
|
78
|
|
|
* Height of the injected canvas, in percentage. |
|
79
|
|
|
* |
|
80
|
|
|
* @param int|float $width |
|
81
|
|
|
* @return CanvasCMPTIF |
|
82
|
|
|
*/ |
|
83
|
1 |
|
public function width(float $width = 100): CanvasCMPTIF |
|
84
|
|
|
{ |
|
85
|
1 |
|
$this->dom_attributes['width'] = $width; |
|
86
|
1 |
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
} |