-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows.js
42 lines (35 loc) · 820 Bytes
/
windows.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
function Window(child)
{
this.child = child;
child.parent = this;
// transparent background and border by default
this.background = "rgba(0, 0, 0, 0.3)";
this.border = "rgba(0, 0, 0, 0.3)";
}
Window.prototype.getBoundingBox = function()
{
return this.boundingBox;
}
Window.prototype.setBoundingBox = function(x, y, width, height)
{
this.boundingBox = new Rectangle(x, y, width, height);
}
Window.prototype.setChild = function(child)
{
this.child = child;
}
Window.prototype.getChild = function()
{
return this.child;
}
Window.prototype.render = function(ctx)
{
var b = this.getBoundingBox();
ctx.save();
ctx.fillStyle = this.background;
ctx.fillRect(b.x, b.y, b.width, b.height);
ctx.strokeStyle = this.border;
ctx.strokeRect(b.x, b.y, b.width, b.height);
this.child.render(ctx);
ctx.restore();
}