From 3dbd6bc91bc8c3719c35938a3bc4622e4f88881d Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 6 May 2011 15:03:21 +0100 Subject: [PATCH 1/7] Some simplifications to the roundRectangle example. --- examples/Scripts/roundRectangle.html | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/Scripts/roundRectangle.html b/examples/Scripts/roundRectangle.html index 584f861a..52f3900b 100644 --- a/examples/Scripts/roundRectangle.html +++ b/examples/Scripts/roundRectangle.html @@ -7,16 +7,18 @@ From 29863b852a9fb2bad8bde7bbb504181bbb210b55 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 6 May 2011 15:34:27 +0100 Subject: [PATCH 2/7] BouncingBalls example: use onFrame for animation and simplify some things. --- examples/Scripts/BouncingBalls.html | 59 +++++++++++------------------ 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/examples/Scripts/BouncingBalls.html b/examples/Scripts/BouncingBalls.html index 2b5de007..afb5a36c 100644 --- a/examples/Scripts/BouncingBalls.html +++ b/examples/Scripts/BouncingBalls.html @@ -7,15 +7,13 @@

Click to add circles:

- + \ No newline at end of file From 74dd89a68ba94632c38d7f73a685121ce9d4d5a0 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 6 May 2011 15:37:55 +0100 Subject: [PATCH 3/7] Use Point#read in Point#min and Point#max. --- src/basic/Point.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/basic/Point.js b/src/basic/Point.js index a66525e1..f1148603 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -492,6 +492,8 @@ var Point = this.Point = Base.extend({ * @return The newly created point object */ min: function(point1, point2) { + point1 = Point.read(arguments, 0, 1); + point2 = Point.read(arguments, 1, 1); return Point.create( Math.min(point1.x, point2.x), Math.min(point1.y, point2.y) @@ -515,6 +517,8 @@ var Point = this.Point = Base.extend({ * @return The newly created point object */ max: function(point1, point2) { + point1 = Point.read(arguments, 0, 1); + point2 = Point.read(arguments, 1, 1); return Point.create( Math.max(point1.x, point2.x), Math.max(point1.y, point2.y) From 1587ac857dd043b5e97bc64b850e0a6f864c9f26 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 6 May 2011 15:51:26 +0100 Subject: [PATCH 4/7] Simplify Circles example. --- examples/Tools/Circles.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/Tools/Circles.html b/examples/Tools/Circles.html index d2271405..787cc4b7 100644 --- a/examples/Tools/Circles.html +++ b/examples/Tools/Circles.html @@ -16,17 +16,13 @@ var path; function onMouseDrag(event) { - if (path) path.remove(); // The radius is the distance between the position // where the user clicked and the current position // of the mouse. var radius = (event.downPoint - event.point).length; path = new Path.Circle(event.downPoint, radius); + path.removeOnDrag(); }; - - function onMouseUp(event) { - path = null; - } From c05eb9bfde11dbbbad09520fb7a53efe8b7797a5 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 6 May 2011 15:54:36 +0100 Subject: [PATCH 5/7] Rework the Clouds example a bit. --- examples/Tools/Clouds.html | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/Tools/Clouds.html b/examples/Tools/Clouds.html index a6a0f23d..875fce6f 100644 --- a/examples/Tools/Clouds.html +++ b/examples/Tools/Clouds.html @@ -7,19 +7,27 @@ From 020ab4e8bb4af92aa062c201608f45582122f41c Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 6 May 2011 17:11:46 +0100 Subject: [PATCH 6/7] Some work on the Worm Farm example. --- examples/Tools/Worm Farm.html | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/examples/Tools/Worm Farm.html b/examples/Tools/Worm Farm.html index 223810ce..e96583d3 100644 --- a/examples/Tools/Worm Farm.html +++ b/examples/Tools/Worm Farm.html @@ -12,13 +12,21 @@ var values = { minDistance: 10, + maxDistance: 30, varyThickness: true }; + // All newly created items will inherit the following styles: + document.currentStyle = { + fillColor: 'white', + strokeColor: 'black' + }; + ///////////////////////////////////////////////////////////////////// // Mouse handling tool.minDistance = values.minDistance; + tool.maxDistance = values.maxDistance; var worm; @@ -26,9 +34,8 @@ // and when a user drags the mouse we add points to it function onMouseDown(event) { worm = new Path(); - worm.fillColor = '#ffffff'; - worm.strokeColor = '#000000'; - worm.add(event.point); + worm.add(event.point, event.point); + worm.closed = true; } function onMouseDrag(event) { @@ -62,22 +69,18 @@ // add the top point to the end of the path worm.add(top); - // insert the bottom point in the beginning of the path - worm.insert(0, bottom); + // insert the bottom point after the first segment of the path + worm.insert(1, bottom); // make a new line path from top to bottom var line = new Path.Line(top, bottom); - line.strokeColor = '#000000'; + + // This is the point at the front of the worm: + worm.firstSegment.point = event.point; // smooth the segments of the path worm.smooth(); } - - function onMouseUp(event) { - worm.closed = true; - worm.add(event.point); - worm.smooth(); - } From 314619e0a39dac528ba7e13e7d58aa5d6024fd1e Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 6 May 2011 17:38:01 +0100 Subject: [PATCH 7/7] Simplify Worm Farm example. --- examples/Tools/Worm Farm.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Tools/Worm Farm.html b/examples/Tools/Worm Farm.html index e96583d3..2413dc9e 100644 --- a/examples/Tools/Worm Farm.html +++ b/examples/Tools/Worm Farm.html @@ -73,7 +73,7 @@ worm.insert(1, bottom); // make a new line path from top to bottom - var line = new Path.Line(top, bottom); + new Path(top, bottom); // This is the point at the front of the worm: worm.firstSegment.point = event.point;