mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
RadialRainbows.html example: use onFrame instead of setInterval and fix a bug in the window resizing code.
This commit is contained in:
parent
ba6139cd48
commit
d2de9c29d7
1 changed files with 7 additions and 8 deletions
|
@ -42,16 +42,14 @@
|
||||||
vector.length = 10;
|
vector.length = 10;
|
||||||
mouseDown = false;
|
mouseDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onFrame() {
|
||||||
|
if (!mouseDown)
|
||||||
|
iterate();
|
||||||
|
}
|
||||||
|
|
||||||
var grow = false;
|
var grow = false;
|
||||||
var vector = new Point(150, 0);
|
var vector = new Point(150, 0);
|
||||||
setInterval(draw, 30);
|
|
||||||
function draw() {
|
|
||||||
if (!mouseDown) {
|
|
||||||
iterate();
|
|
||||||
document.redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function iterate() {
|
function iterate() {
|
||||||
for (var i = 0, l = gradient.stops.length; i < l; i++)
|
for (var i = 0, l = gradient.stops.length; i < l; i++)
|
||||||
|
@ -73,7 +71,8 @@
|
||||||
var radius = Math.max(document.size.height, document.size.width) * 0.75;
|
var radius = Math.max(document.size.height, document.size.width) * 0.75;
|
||||||
var gradientColor = path.fillColor;
|
var gradientColor = path.fillColor;
|
||||||
gradientColor.origin = point;
|
gradientColor.origin = point;
|
||||||
gradientColor.origin = point + radius;
|
var radius = Math.max(document.size.height, document.size.width) * 0.75;
|
||||||
|
gradientColor.destination = point + [radius, 0];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue