Have Path#closePath() handle merging of first and last segment, if doubled.

So we finally found a reason for #closePath() to stick around :)
This commit is contained in:
Jürg Lehni 2013-03-19 18:47:18 -07:00
parent 30b7891a1d
commit 5ff911f68c
2 changed files with 7 additions and 1 deletions

View file

@ -241,7 +241,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
},
closePath: function() {
getCurrentPath(this).setClosed(true);
getCurrentPath(this).closePath();
}
};

View file

@ -2202,6 +2202,12 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
},
closePath: function() {
var first = this.getFirstSegment(),
last = this.getLastSegment();
if (first._point.equals(last._point)) {
first.setHandleIn(last._handleIn);
last.remove();
}
this.setClosed(true);
}
};