HTML and CSS Reference
In-Depth Information
draw2
called by drawface in 2 faces for 2 and 3
draw4
called by drawface in 3 places for 4, 5 and 6
draw2mid
called by drawface in 1 place for 6
Table 2-2. The Complete Code for the Throwing a Single Die Application
Code
Explanation
<html>
Opening html tag
<head>
Opening head tag
<title>Throwing 1 die</title>
Full title element
<script>
Opening script tag
var cwidth = 400;
Variable holding the width of the canvas; also
used to erase the canvas to prepare for redrawing
var cheight = 300;
Variable holding the height of the canvas; also
used to erase the canvas to prepare for redrawing
var dicex = 50;
Variable holding the horizontal position of the
single die
var dicey = 50;
Variable holding the vertical position of the single
die
var dicewidth = 100;
Variable holding the width of a die face
var diceheight = 100;
Variable holding the height of a die face
var dotrad = 6;
Variable holding the radius of a dot
var ctx;
Variable holding the canvas context, used in all
the draw commands
function init() {
Start of the function definition for the init
function, which is invoked onLoad of the
document
 
Search WWH ::




Custom Search