From 4d9c0c9f05b1dded2a0af969925cd1f6622c8434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 19 Jul 2016 19:09:23 +0200 Subject: [PATCH] Implement CompoundPath#getLength() --- src/path/CompoundPath.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 66f33b8a..47adf7cb 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -283,6 +283,21 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{ for (var i = 0, l = children.length; i < l; i++) area += children[i].getArea(); return area; + }, + + /** + * The total length of all sub-paths in this compound-path, calculated by + * getting {@link Path#getLength()} of each sub-path and it adding up. + * + * @bean + * @type Number + */ + getLength: function() { + var children = this._children, + length = 0; + for (var i = 0, l = children.length; i < l; i++) + length += children[i].getLength(); + return length; } }, /** @lends CompoundPath# */{ // Enforce bean creation for getPathData(), as it has hidden parameters.