Tool example documentation.

This commit is contained in:
Jonathan Puckey 2013-03-03 18:56:11 +01:00
parent 419d9f21af
commit d4c0386e5b

View file

@ -142,8 +142,11 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{
* function onMouseDown(event) { * function onMouseDown(event) {
* // Create a new circle shaped path with a radius of 10 * // Create a new circle shaped path with a radius of 10
* // at the position of the mouse (event.point): * // at the position of the mouse (event.point):
* var path = new Path.Circle(event.point, 10); * var path = new Path.Circle({
* path.fillColor = 'black'; * center: event.point,
* radius: 10,
* fillColor: 'black'
* });
* } * }
*/ */
@ -160,8 +163,9 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{
* // Draw a line by adding a segment to a path on every mouse drag event: * // Draw a line by adding a segment to a path on every mouse drag event:
* *
* // Create an empty path: * // Create an empty path:
* var path = new Path(); * var path = new Path({
* path.strokeColor = 'black'; * strokeColor: 'black'
* });
* *
* function onMouseDrag(event) { * function onMouseDrag(event) {
* // Add a segment to the path at the position of the mouse: * // Add a segment to the path at the position of the mouse:
@ -182,8 +186,11 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{
* // Moving a path to the position of the mouse: * // Moving a path to the position of the mouse:
* *
* // Create a circle shaped path with a radius of 10 at {x: 0, y: 0}: * // Create a circle shaped path with a radius of 10 at {x: 0, y: 0}:
* var path = new Path.Circle([0, 0], 10); * var path = new Path.Circle({
* path.fillColor = 'black'; * center: [0, 0],
* radius: 10,
* fillColor: 'black'
* });
* *
* function onMouseMove(event) { * function onMouseMove(event) {
* // Whenever the user moves the mouse, move the path * // Whenever the user moves the mouse, move the path
@ -206,8 +213,11 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{
* function onMouseUp(event) { * function onMouseUp(event) {
* // Create a new circle shaped path with a radius of 10 * // Create a new circle shaped path with a radius of 10
* // at the position of the mouse (event.point): * // at the position of the mouse (event.point):
* var path = new Path.Circle(event.point, 10); * var path = new Path.Circle({
* path.fillColor = 'black'; * 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: * // Scaling a path whenever the user presses the space bar:
* *
* // Create a circle shaped path: * // Create a circle shaped path:
* var path = new Path.Circle(new Point(50, 50), 30); * var path = new Path.Circle({
* path.fillColor = 'red'; * center: new Point(50, 50),
* radius: 30,
* fillColor: 'red'
* });
* *
* function onKeyDown(event) { * function onKeyDown(event) {
* if (event.key == 'space') { * if (event.key == 'space') {