Document Path#lineBy(vector).

This commit is contained in:
Jonathan Puckey 2011-06-10 13:32:37 +02:00
parent ac703f1baa
commit 87c1b564d2

View file

@ -1825,9 +1825,52 @@ var Path = this.Path = PathItem.extend({
this._add(segments);
},
// DOCS: document Path#lineBy
/**
* @param {Point} vector
* Adds a segment relative to the last segment point of the path.
*
* @param {Point} vector The vector which is added to the position
* of the last segment of the path, to become the new segment.
*
* @example {@paperscript}
* var path = new Path();
* path.strokeColor = 'black';
*
* // Add a segment at {x: 50, y: 50}
* path.add(25, 25);
*
* // Add a segment relative to the last segment of the path.
* // 50 in x direction and 0 in y direction, becomes {x: 75, y: 25}
* path.lineBy(50, 0);
*
* // 0 in x direction and 50 in y direction, becomes {x: 75, y: 75}
* path.lineBy(0, 50);
*
* @example {@paperscript height=300}
* // Drawing a spiral using lineBy:
* var path = new Path();
* path.strokeColor = 'black';
*
* // Add the first segment at {x: 50, y: 50}
* path.add(view.center);
*
* // Loop 500 times:
* for (var i = 0; i < 500; i++) {
* // Create a vector with an ever increasing length
* // and an angle in increments of 45 degrees
* var vector = new Point({
* angle: i * 45,
* length: i / 2
* });
* // Add the vector relatively to the last segment point:
* path.lineBy(vector);
* }
*
* // Smooth the handles of the path:
* path.smooth();
*
* // Uncomment the following line and click on 'run' to see
* // the construction of the path:
* // path.selected = true;
*/
lineBy: function(vector) {
vector = Point.read(arguments);