HTML and CSS Reference
In-Depth Information
Code
Explanation
… = String(0);
(and it actually isn't necessary since
JavaScript will convert a number to a string in
this situation)
ctx = document.getElementById
('canvas').getContext('2d');
Set the variable to be used for all drawing
canvas1
=
document.getElementById
Set the variable to be used for the mouse
click event handling
('canvas');
canvas1.addEventListener
('click',choose,false);
Set up click event handling
drawall();
Draw everything
ctx.font="bold 16pt Georgia";
Set the font to be used for the result
messages
ctx.fillStyle = "blue";
Set the color
}
Close the function
function drawall() {
Header for the function
ctx.clearRect(0,0,cwidth,cheight);
Clear the canvas
var i;
Variable for indexing
for (i=0;i<everything.length;i++) {
Iterate through the everything array
everything[i].draw();
Draw the individual elements
Close the for loop
}
}
Close the function
</script>
Close the script element
</head>
Close the head element
<body onLoad="init();">
Starting body tag. Set up call to the init
function
Search WWH ::




Custom Search