User:Yoana Buzova/canvas: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 19: Line 19:


function draw(){
function draw(){
   setInterval('drawing()',50);
   setInterval('function(){drawing()}',50);
}
}



Revision as of 17:20, 15 October 2012

<canvas id="canvas" width="900" height="400" showsrc> var p; i = 0; function drawing(){

 c = document.getElementById("canvas"); 
 console.log("test");
 p = c.getContext("2d"); 
 p.fillStyle = "#000000";
 p.fillRect( 0, 0, 900, 400);
 p.fillStyle = "#11CCBC";
 drawBlocks();
 p.fillStyle = "#FFFF00";
 p.fillRect(12*i, 0, 12, 400);
 if(i*12>900){i=0;}
 i+=1;

}

function draw(){

 setInterval('function(){drawing()}',50);

}

function drawBlocks(){

    x = 0;
    counter = 0;

while (counter < 100) { p.fillRect(x, 0, 12 , 400); x = x + 25; counter = counter + 1;

    }

} </canvas>