Piešia kvadratukus ant pelės
// WELCOME TO THE CANVAS ANIMATION PLAYGROUND! // Global variables and functions go here. It's important that all variables // must be declared here (if even they don't have an initial value. Otherwise, // your animation will not run. // VARIABLES var x = -100, y = -100, step = 5; function getMousePos(canvas, evt) { var rect = canvas.getBoundingClientRect(); return { x: evt.clientX - rect.left, y: evt.clientY - rect.top }; } CVS.addEventListener('mousemove', function(evt) { var mousePos = getMousePos(CVS, evt); //ar message = 'Mouse position: ' + mousePos.x + ',' + mousePos.y; x = mousePos.x; y = mousePos.y; //writeMessage(canvas, message); }, false); plotRandomArc(); function plotRandomArc() { //if (x == -1) return; var ctx = CTX; //x = Math.round(Math.random()*CVS.width); //y = Math.round(Math.random()*CVS.height); //x = event.clientX; // Get the horizontal coordinate //y = event.clientY; // Get the vertical coordinate step = Math.round(Math.random()*130); //console.log(x,y,step); ctx.beginPath(); ctx.fillStyle = "#"+Math.round(Math.random() * 255*255*255).toString(16); //Math.round(Math.random()*130) step = Math.round(Math.random()*10); //ctx.arc(x,y,step,0,Math.random()*6*Math.PI); ctx.fillRect(x,y,Math.round(Math.random()*100),Math.round(Math.random()*100)); //ctx.fill(); setTimeout(plotRandomArc, 100); var coor = "X coords: " + x + ", Y coords: " + y; console.log("x="+x+"; y="+y+";"); } // CANVAS ANIMATION LOOP (CALLED EVERY FRAME) var CanvasAnimationLoop = function() { };