mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Update lines example to use onFrame.
This commit is contained in:
parent
520e540da7
commit
8f3e6f44a7
1 changed files with 5 additions and 14 deletions
|
@ -14,10 +14,10 @@
|
||||||
path.closed = true;
|
path.closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = document.bounds.center;
|
var position = document.bounds.center,
|
||||||
var mousePos = position;
|
mousePos = position,
|
||||||
var children = document.activeLayer.children;
|
children = document.activeLayer.children,
|
||||||
var count = 0;
|
count = 0;
|
||||||
|
|
||||||
function iterate() {
|
function iterate() {
|
||||||
count++;
|
count++;
|
||||||
|
@ -35,21 +35,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onFrame() {
|
||||||
var lastRedraw = 0;
|
|
||||||
setInterval(draw, 30);
|
|
||||||
function draw() {
|
|
||||||
iterate();
|
iterate();
|
||||||
var now = new Date().getTime();
|
|
||||||
if(now - lastRedraw > 30) {
|
|
||||||
document.redraw();
|
|
||||||
lastRedraw = now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseMove(event) {
|
function onMouseMove(event) {
|
||||||
iterate();
|
iterate();
|
||||||
lastRedraw = Date.now();
|
|
||||||
mousePos = event.point;
|
mousePos = event.point;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue