HTML and CSS Reference
In-Depth Information
Coarse Scrolling Full Code Example
Example 9-2
,
shows the full code listing for the Coarse Scrolling example. The code for this
is a little bit simpler than the Fine Scrolling version because we do not need the
rowBuffer
and
colBuffer
variables. We also do not need to the matrix transformation to translate the
Canvas.Wesimplyneedtopaintthecurrentsetoftilesandwillneverneedtopaintanypartial
tiles as we would with Fine scrolling.
Example 9-2. Coarse scrolling
<!doctype html>
<html
<html lang=
"en"
>
<head>
<head>
<meta
<meta charset=
"UTF-8"
>
<title>
<title>
CH9 EX3 - Scrolling Test 1 coarse scrolling
</title>
</title>
<
script src
=
"modernizr.min.js"
><
/script>
<
script type
=
"text/javascript"
>
window
.
addEventListener
(
'load'
,
eventWindowLoaded
,
false
false
);
function
function
eventWindowLoaded
() {
canvasApp
();
}
<
/script>
<
script language
=
"Javascript"
>
function
function
canvasSupport
() {
return
return
Modernizr
.
canvas
;
}
function
function
canvasApp
(){
iif
(
!
canvasSupport
()) {
return
return
;
}
else
else
{
var
var
theCanvas
=
document
.
getElementById
(
'canvas'
);
var
var
context
=
theCanvas
.
getContext
(
'2d'
);
}