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-4. The Complete Two-Dice Application
Code
Explanation
<html>
Opening html tag
<head>
Opening head tag
<title>Throwing dice</title>
Full title element
<script>
Opening script tag
var cwidth = 400;
Variable holding the width of the canvas
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; also used to erase the canvas to
prepare for redrawing
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
var dx;
Variable used for horizontal positioning and
changed for each of the two die faces
 
Search WWH ::




Custom Search