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));
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);

View file

@ -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;

View file

@ -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]);

View file

@ -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) {