mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Examples: change mouse handlers to PaperScript.
This commit is contained in:
parent
e1a6c4f3d0
commit
bb5bfe1fb1
4 changed files with 26 additions and 28 deletions
|
@ -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) {
|
|
||||||
gradientColor.hilite = event.point;
|
function onMouseDrag(event) {
|
||||||
},
|
gradientColor.hilite = event.point;
|
||||||
onMouseUp: function(event) {
|
}
|
||||||
mouseDown = false;
|
|
||||||
}
|
function onMouseUp(event) {
|
||||||
});
|
mouseDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
setInterval(draw, 30);
|
setInterval(draw, 30);
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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]);
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
var strokePoints = strokeEnds * 2 + 1;
|
var strokePoints = strokeEnds * 2 + 1;
|
||||||
point -= step / 2;
|
point -= step / 2;
|
||||||
step /= strokePoints - 1;
|
step /= strokePoints - 1;
|
||||||
for(var i = 0; i < strokePoints; i++) {
|
for (var i = 0; i < strokePoints; i++) {
|
||||||
var strokePoint = point + step * i;
|
var strokePoint = point + step * i;
|
||||||
var offset = delta * (Math.random() * 0.3 + 0.1);
|
var offset = delta * (Math.random() * 0.3 + 0.1);
|
||||||
if (i % 2) {
|
if (i % 2) {
|
||||||
|
|
Loading…
Reference in a new issue