From bb5bfe1fb1eb0bbd43fb9a2d9a7c70e710f4c376 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Fri, 4 Mar 2011 12:44:02 +0100 Subject: [PATCH] Examples: change mouse handlers to PaperScript. --- examples/Animated/RadialRainbows.html | 25 ++++++++++++------------ examples/Animated/RoundedRectangles.html | 8 +++----- examples/Scripts/BouncingBalls.html | 19 +++++++++--------- examples/Tools/Fancy Brush.html | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/examples/Animated/RadialRainbows.html b/examples/Animated/RadialRainbows.html index 536952c2..558bef87 100644 --- a/examples/Animated/RadialRainbows.html +++ b/examples/Animated/RadialRainbows.html @@ -52,18 +52,19 @@ var path = new Path.Rectangle(new Rectangle([0, 0], document.size)); path.fillColor = gradientColor; var mouseDown = false; - var tool = new Tool({ - onMouseDown: function(event) { - mouseDown = true; - gradientColor.hilite = event.point; - }, - onMouseDrag: function(event) { - gradientColor.hilite = event.point; - }, - onMouseUp: function(event) { - mouseDown = false; - } - }); + + function onMouseDown(event) { + mouseDown = true; + gradientColor.hilite = event.point; + } + + function onMouseDrag(event) { + gradientColor.hilite = event.point; + } + + function onMouseUp(event) { + mouseDown = false; + } setInterval(draw, 30); diff --git a/examples/Animated/RoundedRectangles.html b/examples/Animated/RoundedRectangles.html index 97316bc1..d2bd1174 100644 --- a/examples/Animated/RoundedRectangles.html +++ b/examples/Animated/RoundedRectangles.html @@ -51,11 +51,9 @@ } setInterval(draw, 30); - var tool = new Tool({ - onMouseDrag: function(event) { - mousePoint = event.point; - } - }); + function onMouseDrag(event) { + mousePoint = event.point; + } var children = document.activeLayer.children; var count = 0; diff --git a/examples/Scripts/BouncingBalls.html b/examples/Scripts/BouncingBalls.html index bc46cff4..2f2c002e 100644 --- a/examples/Scripts/BouncingBalls.html +++ b/examples/Scripts/BouncingBalls.html @@ -99,16 +99,15 @@ } var lastDelta; - tool = new Tool({ - onMouseDrag: function(event) { - lastDelta = event.delta; - }, - onMouseUp: function(event) { - var ball = new Ball(event.point, lastDelta); - balls.push(ball); - lastDelta = null; - } - }); + function onMouseDrag(event) { + lastDelta = event.delta; + } + + function onMouseUp(event) { + var ball = new Ball(event.point, lastDelta); + balls.push(ball); + lastDelta = null; + } setInterval(draw, 30); var boundPath = new Path.Rectangle([-10, -10], [-11, -11]); diff --git a/examples/Tools/Fancy Brush.html b/examples/Tools/Fancy Brush.html index f3f3c852..2cc61816 100644 --- a/examples/Tools/Fancy Brush.html +++ b/examples/Tools/Fancy Brush.html @@ -93,7 +93,7 @@ var strokePoints = strokeEnds * 2 + 1; point -= step / 2; step /= strokePoints - 1; - for(var i = 0; i < strokePoints; i++) { + for (var i = 0; i < strokePoints; i++) { var strokePoint = point + step * i; var offset = delta * (Math.random() * 0.3 + 0.1); if (i % 2) {