mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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));
|
||||
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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue