Name: Anonymous 2011-11-29 5:08
plz review my codes
<!doctype html>
<head>
</head>
<body>
<canvas id="example" width="2000" height="2000">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
<script>
var example = document.getElementById('example');
var context = example.getContext('2d');
var timeout;
var timeoutvalue=1000;
foo();
function clear(invert)
{
if (invert) {
context.fillStyle = "rgb(0,0,0)";
}
else {
context.fillStyle = "rgb(255,255,255)";
}
context.fillRect(0, 0, example.width, example.height);
}
function checkerboard(v,l)
{
var x=0;
var y=0;
for(y=0;y<8;y++) {
for(x=0;x<8;x++) {
if (((x+y+v)%2)!=0) {
context.fillStyle="rgb(0,0,0)";
context.fillRect(x*l,y*l,l,l);
}
}
}
}
function foo()
{
clear(0);
checkerboard(0,example.width/8);
timeout=setTimeout("bar()",timeoutvalue);
}
function bar()
{
clear(0);
checkerboard(1,example.width/8);
timeout=setTimeout("foo()",timeoutvalue);
}
</script>
</body>
</html>