From 0d2779dfc5d8ef1459ce22e5fe9a8f930a0f8a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 10 Jun 2016 14:53:52 +0200 Subject: [PATCH] Docs: Define default value for PathItem#flatten() And some other minor cleanups. --- src/path/Path.js | 11 ++++++----- src/path/PathItem.js | 12 ++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/path/Path.js b/src/path/Path.js index a412c4bb..fd7b172f 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -876,7 +876,7 @@ var Path = PathItem.extend(/** @lends Path# */{ * @example {@paperscript} * // Selecting an item: * var path = new Path.Circle({ - * center: new Size(80, 50), + * center: [80, 50], * radius: 35 * }); * path.selected = true; // Select the path @@ -884,7 +884,7 @@ var Path = PathItem.extend(/** @lends Path# */{ * @example {@paperscript} * // A path is selected, if one or more of its segments is selected: * var path = new Path.Circle({ - * center: new Size(80, 50), + * center: [80, 50], * radius: 35 * }); * @@ -907,13 +907,13 @@ var Path = PathItem.extend(/** @lends Path# */{ * @example {@paperscript} * // A path is fully selected, if all of its segments are selected: * var path = new Path.Circle({ - * center: new Size(80, 50), + * center: [80, 50], * radius: 35 * }); * path.fullySelected = true; * * var path2 = new Path.Circle({ - * center: new Size(180, 50), + * center: [180, 50], * radius: 35 * }); * @@ -1209,8 +1209,9 @@ var Path = PathItem.extend(/** @lends Path# */{ */ reduce: function(options) { var curves = this.getCurves(), + // TODO: Find a better name, to not confuse with PathItem#simplify() simplify = options && options.simplify, - // When not simplifying, only remove curves if their length is + // When not simplifying, only remove curves if their lengths are // absolutely 0. tolerance = simplify ? /*#=*/Numerical.GEOMETRIC_EPSILON : 0; for (var i = curves.length - 1; i >= 0; i--) { diff --git a/src/path/PathItem.js b/src/path/PathItem.js index 3073f1e6..d8246f76 100644 --- a/src/path/PathItem.js +++ b/src/path/PathItem.js @@ -415,8 +415,8 @@ var PathItem = Item.extend(/** @lends PathItem# */{ * @name PathItem#flatten * @function * - * @param {Number} flatness the maximum error between the flattened lines - * and the original curves + * @param {Number} [flatness=0.25] the maximum error between the flattened + * lines and the original curves * * @example {@paperscript} * // Flattening a circle shaped path: @@ -424,19 +424,19 @@ var PathItem = Item.extend(/** @lends PathItem# */{ * // Create a circle shaped path at { x: 80, y: 50 } * // with a radius of 35: * var path = new Path.Circle({ - * center: new Size(80, 50), + * center: [80, 50], * radius: 35 * }); * * // Select the path, so we can inspect its segments: * path.selected = true; * - * // Create a copy of the path and move it 150 points to the right: + * // Create a copy of the path and move it by 150 points: * var copy = path.clone(); * copy.position.x += 150; * - * // Convert its curves to points, with a maximum error of 10: - * copy.flatten(10); + * // Flatten the copied path, with a maximum error of 4 points: + * copy.flatten(4); */ // TODO: Write about negative indices, and add an example for ranges.