Animation: requestAnimationFrame(animate)
Framerate: setTimeout (function(){…anim-code inkl. requestAnimFrame…},1000/fps);
var fps = 100;
function animate() {
setTimeout(function(){
var arrayLength = forms.length;
for (var i = 0; i < arrayLength; i++) {
forms[i].scale();
}
form = new Form(x, y);
if (fps>1)
{fps=fps-1;}
else{fps=0.3;}
// alert(fps);
forms.push(form);
var arrayLength = forms.length;
for (var i = 0; i < arrayLength; i++) {
draw_form(forms[i], ctx);
}
var min = -100;
var max = window.innerWidth;
// and the formula is:
var random = Math.floor(Math.random() * (max – min + 1)) + min;
x = random;
var random = Math.floor(Math.random() * (max – min + 1)) + min;
y = random;
requestAnimationFrame(animate);
},1000/fps);
}