2011-02-17 10:00:20 -05:00
|
|
|
module('Compound Path');
|
|
|
|
|
|
|
|
test('moveTo / lineTo', function() {
|
|
|
|
var path = new CompoundPath();
|
|
|
|
|
|
|
|
var lists = [
|
|
|
|
[new Point(279, 151), new Point(149, 151), new Point(149, 281), new Point(279, 281)],
|
|
|
|
[new Point(319, 321), new Point(109, 321), new Point(109, 111), new Point(319, 111)]
|
|
|
|
];
|
|
|
|
|
|
|
|
for (var i = 0; i < lists.length; i++) {
|
|
|
|
var list = lists[i];
|
|
|
|
for (var j = 0; j < list.length; j++) {
|
|
|
|
path[j == 0 ? 'moveTo' : 'lineTo'](list[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
path.fillColor = 'black';
|
|
|
|
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return path.children.length;
|
2011-05-15 14:09:34 -04:00
|
|
|
}, 2);
|
|
|
|
});
|
2011-05-15 14:10:12 -04:00
|
|
|
|
|
|
|
test('clockwise', function() {
|
|
|
|
var path1 = new Path.Rectangle([200, 200], [100, 100]);
|
|
|
|
var path2 = new Path.Rectangle([50, 50], [200, 200]);
|
|
|
|
var path3 = new Path.Rectangle([0, 0], [400, 400]);
|
|
|
|
|
|
|
|
equals(function() {
|
|
|
|
return path1.clockwise;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return path2.clockwise;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return path3.clockwise;
|
|
|
|
}, true);
|
|
|
|
|
2011-05-16 15:16:51 -04:00
|
|
|
var compound = new CompoundPath(path1, path2, path3);
|
2011-05-15 14:10:12 -04:00
|
|
|
|
2011-05-16 15:16:51 -04:00
|
|
|
equals(function() {
|
|
|
|
return compound.lastChild == path3;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return compound.firstChild == path1;
|
|
|
|
}, true);
|
2011-05-15 14:10:12 -04:00
|
|
|
equals(function() {
|
|
|
|
return path1.clockwise;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return path2.clockwise;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return path3.clockwise;
|
|
|
|
}, false);
|
|
|
|
})
|