Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

HTML5 canvas checkerboard animation

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>

Name: Anonymous 2011-11-29 5:11

HTML is not programming !!!

Name: Anonymous 2011-11-29 5:13

>>2
but javascript is touring complete

Name: Anonymous 2011-11-29 6:11

HTML5
Let me know when it's finalized.

Name: Anonymous 2011-11-29 6:34

>>4
Good joke, sir.

Name: Anonymous 2011-11-29 7:07

Multiple vars considered harmful, use commas instead.

Name: Anonymous 2011-11-29 8:21

>>4
Why? You can use it now!

Don't change these.
Name: Email:
Entire Thread Thread List