Examples: change mouse handlers to PaperScript.

This commit is contained in:
Jonathan Puckey 2011-03-04 12:44:02 +01:00
parent e1a6c4f3d0
commit bb5bfe1fb1
4 changed files with 26 additions and 28 deletions

View file

@ -52,18 +52,19 @@
var path = new Path.Rectangle(new Rectangle([0, 0], document.size)); var path = new Path.Rectangle(new Rectangle([0, 0], document.size));
path.fillColor = gradientColor; path.fillColor = gradientColor;
var mouseDown = false; var mouseDown = false;
var tool = new Tool({
onMouseDown: function(event) { function onMouseDown(event) {
mouseDown = true; mouseDown = true;
gradientColor.hilite = event.point; gradientColor.hilite = event.point;
}, }
onMouseDrag: function(event) {
function onMouseDrag(event) {
gradientColor.hilite = event.point; gradientColor.hilite = event.point;
}, }
onMouseUp: function(event) {
function onMouseUp(event) {
mouseDown = false; mouseDown = false;
} }
});
setInterval(draw, 30); setInterval(draw, 30);

View file

@ -51,11 +51,9 @@
} }
setInterval(draw, 30); setInterval(draw, 30);
var tool = new Tool({ function onMouseDrag(event) {
onMouseDrag: function(event) {
mousePoint = event.point; mousePoint = event.point;
} }
});
var children = document.activeLayer.children; var children = document.activeLayer.children;
var count = 0; var count = 0;

View file

@ -99,16 +99,15 @@
} }
var lastDelta; var lastDelta;
tool = new Tool({ function onMouseDrag(event) {
onMouseDrag: function(event) {
lastDelta = event.delta; lastDelta = event.delta;
}, }
onMouseUp: function(event) {
function onMouseUp(event) {
var ball = new Ball(event.point, lastDelta); var ball = new Ball(event.point, lastDelta);
balls.push(ball); balls.push(ball);
lastDelta = null; lastDelta = null;
} }
});
setInterval(draw, 30); setInterval(draw, 30);
var boundPath = new Path.Rectangle([-10, -10], [-11, -11]); var boundPath = new Path.Rectangle([-10, -10], [-11, -11]);