From d4c0386e5bb39f26f5f22b170f3286bba31cc800 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sun, 3 Mar 2013 18:56:11 +0100 Subject: [PATCH] Tool example documentation. --- src/tool/Tool.js | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/tool/Tool.js b/src/tool/Tool.js index f263ce7a..9e223da3 100644 --- a/src/tool/Tool.js +++ b/src/tool/Tool.js @@ -142,8 +142,11 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{ * function onMouseDown(event) { * // Create a new circle shaped path with a radius of 10 * // at the position of the mouse (event.point): - * var path = new Path.Circle(event.point, 10); - * path.fillColor = 'black'; + * var path = new Path.Circle({ + * center: event.point, + * radius: 10, + * fillColor: 'black' + * }); * } */ @@ -160,9 +163,10 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{ * // Draw a line by adding a segment to a path on every mouse drag event: * * // Create an empty path: - * var path = new Path(); - * path.strokeColor = 'black'; - * + * var path = new Path({ + * strokeColor: 'black' + * }); + * * function onMouseDrag(event) { * // Add a segment to the path at the position of the mouse: * path.add(event.point); @@ -182,9 +186,12 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{ * // Moving a path to the position of the mouse: * * // Create a circle shaped path with a radius of 10 at {x: 0, y: 0}: - * var path = new Path.Circle([0, 0], 10); - * path.fillColor = 'black'; - * + * var path = new Path.Circle({ + * center: [0, 0], + * radius: 10, + * fillColor: 'black' + * }); + * * function onMouseMove(event) { * // Whenever the user moves the mouse, move the path * // to that position: @@ -206,8 +213,11 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{ * function onMouseUp(event) { * // Create a new circle shaped path with a radius of 10 * // at the position of the mouse (event.point): - * var path = new Path.Circle(event.point, 10); - * path.fillColor = 'black'; + * var path = new Path.Circle({ + * center: event.point, + * radius: 10, + * fillColor: 'black' + * }); * } */ @@ -230,8 +240,11 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{ * // Scaling a path whenever the user presses the space bar: * * // Create a circle shaped path: - * var path = new Path.Circle(new Point(50, 50), 30); - * path.fillColor = 'red'; + * var path = new Path.Circle({ + * center: new Point(50, 50), + * radius: 30, + * fillColor: 'red' + * }); * * function onKeyDown(event) { * if (event.key == 'space') {