Completed
Push — master ( c59f6c...f3d74b )
by Marko
02:18
created

Flat::defaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
c 1
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 21, 2016 - 2:19:19 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         Flat.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\Shaders;
25
26
use \AframeVR\Interfaces\ShaderInterface;
27
use \AframeVR\Core\Helpers\ShaderAbstract;
28
29
class Flat extends ShaderAbstract implements ShaderInterface
30
{
31
32
    /**
33
     * Base diffuse color.
34
     *
35
     * @var string $color
36
     */
37
    protected $color = '#fff';
38
39
    /**
40
     * Whether or not material is affected by fog.
41
     *
42
     * @var string $fog
43
     */
44
    protected $fog = 'true';
45
46
    /**
47
     * Height of video (in pixels), if defining a video texture.
48
     *
49
     * @var int $height
50
     */
51
    protected $height = 360;
52
53
    /**
54
     * How many times a texture (defined by src) repeats in the X and Y direction.
55
     *
56
     * @var string $repeat
57
     */
58
    protected $repeat = '1 1';
59
60
    /**
61
     * Image or video texture map.
62
     * Can either be a selector to an <img> or <video>, or an inline URL.
63
     *
64
     * @var string|null $src
65
     */
66
    protected $src = null;
67
68
    /**
69
     * Width of video (in pixels), if defining a video texture.
70
     *
71
     * @var int $width
72
     */
73
    protected $width = 640;
74
    
75
    /**
76
     * Set shader defaults
77
     *
78
     * @return void
79
     */
80 1
    public function defaults()
81
    {
82 1
        $this->color('#fff');
83 1
        $this->fog(true);
84 1
        $this->height(360);
85 1
        $this->repeat(1, 1);
86 1
        $this->src();
87 1
        $this->width(640);
88 1
    }
89
    
90
    /**
91
     * Base diffuse color
92
     *
93
     * @param string $color            
94
     */
95 1
    public function color(string $color)
96
    {
97 1
        $this->color = $color;
98 1
    }
99
100
    /**
101
     * Whether or not material is affected by fog.
102
     *
103
     * @param bool $fog            
104
     */
105 1
    public function fog(bool $fog)
106
    {
107 1
        $this->fog = $fog ? 'true' : 'false';
108 1
    }
109
110
    /**
111
     * Height of video (in pixels), if defining a video texture.
112
     *
113
     * @param int $height            
114
     */
115 1
    public function height(int $height)
116
    {
117 1
        $this->height = $height;
118 1
    }
119
120
    /**
121
     * Repeat
122
     * 
123
     * @param float $x            
124
     * @param float $y            
125
     */
126 1
    public function repeat(float $x, float $y)
127
    {
128 1
        $this->repeat = sprintf('%d %d', $x, $y);
129 1
    }
130
131
    /**
132
     * How many times a texture (defined by src) repeats in the X and Y direction.
133
     *
134
     * @param null|string $src            
135
     */
136 1
    public function src(string $src = null)
137
    {
138 1
        $this->src = $src;
139 1
    }
140
141
    /**
142
     * Width of video (in pixels), if defining a video texture.
143
     *
144
     * @param int $width            
145
     */
146 1
    public function width(int $width)
147
    {
148 1
        $this->width = $width;
149 1
    }
150
}
151