2011-02-12 13:12:23 -05:00
|
|
|
module('Group');
|
|
|
|
|
|
|
|
test('new Group()', function() {
|
|
|
|
var group = new Group();
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
return paper.project.activeLayer.children[0] == group;
|
2011-05-07 12:46:06 -04:00
|
|
|
}, true);
|
2011-02-12 13:12:23 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('new Group([item])', function() {
|
|
|
|
var path = new Path();
|
|
|
|
var group = new Group([path]);
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
return paper.project.activeLayer.children.length;
|
2011-05-14 13:59:04 -04:00
|
|
|
}, 1);
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return group.children[0] == path;
|
|
|
|
}, true);
|
2011-02-16 18:34:16 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Group bounds', function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
paper.project.currentStyle = {
|
2011-04-28 06:56:30 -04:00
|
|
|
strokeWidth: 5,
|
|
|
|
strokeColor: 'black'
|
|
|
|
};
|
2011-05-16 14:21:44 -04:00
|
|
|
|
2011-02-16 18:34:16 -05:00
|
|
|
var path = new Path.Circle([150, 150], 60);
|
|
|
|
var secondPath = new Path.Circle([175, 175], 85);
|
|
|
|
var group = new Group([path, secondPath]);
|
2011-05-16 14:21:44 -04:00
|
|
|
compareRectangles(group.bounds, { x: 90, y: 90, width: 170, height: 170 }, 'group.bounds');
|
|
|
|
compareRectangles(group.strokeBounds, { x: 87.5, y: 87.5, width: 175, height: 175 }, 'group.strokeBounds');
|
2011-04-28 06:56:30 -04:00
|
|
|
|
2011-02-26 12:17:44 -05:00
|
|
|
group.rotate(20);
|
2011-05-16 14:21:44 -04:00
|
|
|
compareRectangles(group.bounds, { x: 89.97681, y: 82.94095, width: 170.04639, height: 177.08224 }, 'group.bounds');
|
|
|
|
compareRectangles(group.strokeBounds, { x: 87.47681, y: 80.44095, width: 175.04639, height: 182.08224 }, 'group.strokeBounds');
|
2011-02-26 12:17:44 -05:00
|
|
|
group.rotate(20, new Point(50, 50));
|
2011-05-16 14:21:44 -04:00
|
|
|
compareRectangles(group.bounds, { x: 39.70692, y: 114.99196, width: 170.00412, height: 180.22401 }, 'group.bounds');
|
|
|
|
compareRectangles(group.strokeBounds, { x: 37.20692, y: 112.49196, width: 175.00412, height: 185.22401 }, 'group.strokeBounds');
|
2011-02-12 13:12:23 -05:00
|
|
|
});
|