Docs: Define default value for PathItem#flatten()

And some other minor cleanups.
This commit is contained in:
Jürg Lehni 2016-06-10 14:53:52 +02:00
parent 964d8cf7d6
commit 0d2779dfc5
2 changed files with 12 additions and 11 deletions

View file

@ -876,7 +876,7 @@ var Path = PathItem.extend(/** @lends Path# */{
* @example {@paperscript} * @example {@paperscript}
* // Selecting an item: * // Selecting an item:
* var path = new Path.Circle({ * var path = new Path.Circle({
* center: new Size(80, 50), * center: [80, 50],
* radius: 35 * radius: 35
* }); * });
* path.selected = true; // Select the path * path.selected = true; // Select the path
@ -884,7 +884,7 @@ var Path = PathItem.extend(/** @lends Path# */{
* @example {@paperscript} * @example {@paperscript}
* // A path is selected, if one or more of its segments is selected: * // A path is selected, if one or more of its segments is selected:
* var path = new Path.Circle({ * var path = new Path.Circle({
* center: new Size(80, 50), * center: [80, 50],
* radius: 35 * radius: 35
* }); * });
* *
@ -907,13 +907,13 @@ var Path = PathItem.extend(/** @lends Path# */{
* @example {@paperscript} * @example {@paperscript}
* // A path is fully selected, if all of its segments are selected: * // A path is fully selected, if all of its segments are selected:
* var path = new Path.Circle({ * var path = new Path.Circle({
* center: new Size(80, 50), * center: [80, 50],
* radius: 35 * radius: 35
* }); * });
* path.fullySelected = true; * path.fullySelected = true;
* *
* var path2 = new Path.Circle({ * var path2 = new Path.Circle({
* center: new Size(180, 50), * center: [180, 50],
* radius: 35 * radius: 35
* }); * });
* *
@ -1209,8 +1209,9 @@ var Path = PathItem.extend(/** @lends Path# */{
*/ */
reduce: function(options) { reduce: function(options) {
var curves = this.getCurves(), var curves = this.getCurves(),
// TODO: Find a better name, to not confuse with PathItem#simplify()
simplify = options && options.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. // absolutely 0.
tolerance = simplify ? /*#=*/Numerical.GEOMETRIC_EPSILON : 0; tolerance = simplify ? /*#=*/Numerical.GEOMETRIC_EPSILON : 0;
for (var i = curves.length - 1; i >= 0; i--) { for (var i = curves.length - 1; i >= 0; i--) {

View file

@ -415,8 +415,8 @@ var PathItem = Item.extend(/** @lends PathItem# */{
* @name PathItem#flatten * @name PathItem#flatten
* @function * @function
* *
* @param {Number} flatness the maximum error between the flattened lines * @param {Number} [flatness=0.25] the maximum error between the flattened
* and the original curves * lines and the original curves
* *
* @example {@paperscript} * @example {@paperscript}
* // Flattening a circle shaped path: * // 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 } * // Create a circle shaped path at { x: 80, y: 50 }
* // with a radius of 35: * // with a radius of 35:
* var path = new Path.Circle({ * var path = new Path.Circle({
* center: new Size(80, 50), * center: [80, 50],
* radius: 35 * radius: 35
* }); * });
* *
* // Select the path, so we can inspect its segments: * // Select the path, so we can inspect its segments:
* path.selected = true; * 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(); * var copy = path.clone();
* copy.position.x += 150; * copy.position.x += 150;
* *
* // Convert its curves to points, with a maximum error of 10: * // Flatten the copied path, with a maximum error of 4 points:
* copy.flatten(10); * copy.flatten(4);
*/ */
// TODO: Write about negative indices, and add an example for ranges. // TODO: Write about negative indices, and add an example for ranges.