Have the CompoundPath constructor reverse the segments of all paths passed to it except for the first one. Introduce 'keepDirection' option to allow importing of already existing CompoundPath items.

This commit is contained in:
Jonathan Puckey 2011-05-14 13:03:18 +02:00
parent 35d51085a1
commit 2bfe42da05

View file

@ -15,12 +15,20 @@
*/
var CompoundPath = this.CompoundPath = PathItem.extend({
initialize: function(items) {
// PORT: port the reversing of segments and keepDirection flag
initialize: function(items, keepDirection) {
this.base();
this.children = [];
if (items) {
for (var i = 0, l = items.length; i < l; i++)
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i];
// All paths except for the first one are reversed when
// creating a compound path, so that they draw holes.
// When keepDirection is set to true, child paths aren't reversed.
if (!keepDirection && i != l - 1)
item.reverse();
this.appendTop(items[i]);
}
}
},