forked from kamicane/art
/
group.js
46 lines (38 loc) · 1.03 KB
/
group.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 Class = require('../../core/class');
var Container = require('../../dom/container');
var Node = require('./node');
module.exports = Class(Node, Container, {
initialize: function(width, height){
this.width = width;
this.height = height;
},
localHitTest: function(x, y){
var i = 0;
var node = this.lastChild;
while (node){
var hit = node.hitTest(x, y);
if (hit) return hit;
node = node.previousSibling;
if (i++ > 100){ debugger; throw new Error('recursion'); }
}
return null;
},
renderLayerTo: function(context, xx, yx, xy, yy, x, y){
if (this._invisible) return;
x = xx * this.x + xy * this.y + x;
y = yx * this.x + yy * this.y + y;
var t = xx;
xx = t * this.xx + xy * this.yx;
xy = t * this.xy + xy * this.yy;
t = yx;
yx = t * this.xx + yy * this.yx;
yy = t * this.xy + yy * this.yy;
var i = 0;
var node = this.firstChild;
while (node){
node.renderTo(context, xx, yx, xy, yy, x, y);
node = node.nextSibling;
if (i++ > 100){ debugger; throw new Error('recursion'); }
}
}
});