User:Yoana Buzova/canvas: Difference between revisions
Yoana Buzova (talk | contribs) (Created page with "<canvas id="c" width="1680" height="800" style="border: 0 solid black" showsrc> var p; i = 0; function draw2(){ c = document.getElementById("canvas"); console.log(...") |
Yoana Buzova (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
<canvas id="c" width=" | <canvas id="c" width="1000" height="800" showsrc> | ||
var p; | var p; | ||
i = 0; | |||
function draw2(){ | function draw2(){ | ||
c = document.getElementById("canvas"); | c = document.getElementById("canvas"); | ||
p = c.getContext("2d"); | p = c.getContext("2d"); | ||
p.fillStyle = "#000000"; | p.fillStyle = "#000000"; | ||
p.fillRect( 0, 0, | p.fillRect( 0, 0, 1000, 800); | ||
p.fillStyle = "#11CCBC"; | p.fillStyle = "#11CCBC"; | ||
drawBlocks(); | drawBlocks(); | ||
p.fillStyle = "#FFFF00"; | p.fillStyle = "#FFFF00"; | ||
p.fillRect(12*i, 0, 12, | p.fillRect(12*i, 0, 12, 1000); | ||
if(i*12> | if(i*12>1000){i=0;} | ||
i+=1; | i+=1; | ||
} | } | ||
Line 26: | Line 25: | ||
counter = 0; | counter = 0; | ||
while (counter < 100) { | while (counter < 100) { | ||
p.fillRect(x, 0, 12 , | p.fillRect(x, 0, 12 , 1000); | ||
x = x + 25; | x = x + 25; | ||
counter = counter + 1; | counter = counter + 1; |
Revision as of 16:10, 15 October 2012
<canvas id="c" width="1000" height="800" showsrc> var p; i = 0; function draw2(){
c = document.getElementById("canvas"); p = c.getContext("2d"); p.fillStyle = "#000000"; p.fillRect( 0, 0, 1000, 800); p.fillStyle = "#11CCBC";
drawBlocks(); p.fillStyle = "#FFFF00"; p.fillRect(12*i, 0, 12, 1000);
if(i*12>1000){i=0;} i+=1;
}
function draw(){
setInterval(function(){draw2()},50);
}
function drawBlocks(){
x = 0; counter = 0;
while (counter < 100) { p.fillRect(x, 0, 12 , 1000); x = x + 25; counter = counter + 1;
}
} </canvas>