-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.js
46 lines (34 loc) · 827 Bytes
/
camera.js
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
var Camera = {
position : { x: 0, y: 0 },
zoom : 1,
rotation : 0,
// getters
GetPosition : function() {
return this.position;
},
GetZoom : function() {
return this.zoom;
},
GetRotation : function() {
return this.rotation;
},
// setters
SetPosition : function(pos) {
this.position = pos;
},
SetZoom : function(z) {
this.zoom = z;
},
SetRotation : function(rot) {
},
// methods
GetViewRectangle : function() {
},
GetViewSize : function() {
},
ApplyTransformation : function(ctx) {
ctx.translate(this.GetPosition().x, this.GetPosition().y);
ctx.scale(this.GetZoom(), this.GetZoom());
ctx.rotate(this.GetRotation());
}
}