forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrigin.js
More file actions
49 lines (35 loc) · 1001 Bytes
/
Copy pathOrigin.js
File metadata and controls
49 lines (35 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Origin Component
// Values are normalized, given in the range 0 to 1.
// Display values contain the calculated pixel values.
var Origin = {
originX: 0.5,
originY: 0.5,
// READ ONLY
displayOriginX: 0,
displayOriginY: 0,
setOrigin: function (x, y)
{
if (x === undefined) { x = 0.5; }
if (y === undefined) { y = x; }
this.originX = x;
this.originY = y;
return this.updateOrigin();
},
setDisplayOrigin: function (x, y)
{
if (x === undefined) { x = 0; }
if (y === undefined) { y = x; }
this.displayOriginX = x;
this.displayOriginY = y;
this.originX = this.width / x;
this.originY = this.height / y;
return this;
},
updateOrigin: function ()
{
this.displayOriginX = Math.round(this.originX * this.width);
this.displayOriginY = Math.round(this.originY * this.height);
return this;
}
};
module.exports = Origin;