JS Canvas als Bild slpeichern

 put_Image(c);

function put_Image(c)
{
    
    var image = c.toDataURL("image/png").replace("image/png", "image/octet-stream");  // here is the most important part because if you dont replace you will get a DOM 18 exception.

window.location.href=image; // it will save locally
            
       
  }
       

Kann ich den Speicherort bestimmen? Oder nur im Browser?

Das Bild vorher auf eine höhere Auflösung skalieren

Canvas Animation Framerate

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);
           
            }