mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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;
|
||||
}
|
||||
|
||||
var position = document.bounds.center;
|
||||
var mousePos = position;
|
||||
var children = document.activeLayer.children;
|
||||
var count = 0;
|
||||
var position = document.bounds.center,
|
||||
mousePos = position,
|
||||
children = document.activeLayer.children,
|
||||
count = 0;
|
||||
|
||||
function iterate() {
|
||||
count++;
|
||||
|
@ -35,21 +35,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
var lastRedraw = 0;
|
||||
setInterval(draw, 30);
|
||||
function draw() {
|
||||
function onFrame() {
|
||||
iterate();
|
||||
var now = new Date().getTime();
|
||||
if(now - lastRedraw > 30) {
|
||||
document.redraw();
|
||||
lastRedraw = now;
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseMove(event) {
|
||||
iterate();
|
||||
lastRedraw = Date.now();
|
||||
mousePos = event.point;
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue