Rename CompoundPath#simplify() to #flatten() to avoid clashes with Path#simplify(), and add Path#flatten(), returning itself.

This commit is contained in:
Jürg Lehni 2012-11-06 10:16:03 -08:00
parent 93447ee533
commit fd8fe9c08e
3 changed files with 11 additions and 3 deletions

View file

@ -69,9 +69,9 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
* the path is moved outside and the compound path is erased.
* Otherwise, the compound path is returned unmodified.
*
* @return {CompoundPath|Path} the simplified compound path
* @return {CompoundPath|Path} the flattened compound path
*/
simplify: function() {
flatten: function() {
if (this._children.length == 1) {
var child = this._children[0];
child.insertAbove(this);

View file

@ -947,6 +947,14 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
return false;
},
/**
* For simple paths, flatten always returns the path itself. See
* {@link CompoundPath#flatten()} for more explanations.
*/
flatten: function() {
return this;
},
/**
* The length of the perimeter of the path.
*

View file

@ -317,7 +317,7 @@ var SvgImporter = this.SvgImporter = new function() {
break;
// http://www.w3.org/TR/SVG/masking.html#ClipPathProperty
case 'clip-path':
var clipPath = getDefinition(value).clone().simplify(),
var clipPath = getDefinition(value).clone().flatten(),
group = new Group([clipPath, item]);
group.clipped = true;
break;