HTML and CSS Reference
In-Depth Information
< script src = "modernizr.js" >< /script>
< script type = "text/javascript" >
window . addEventListener ( 'load' , eventWindowLoaded , false
false );
function
function eventWindowLoaded () {
canvasApp ();
}
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" );
var
var theCanvas2 = document . getElementById ( "canvas2" );
var
var context2 = theCanvas2 . getContext ( "2d" );
}
var
var tileSheet = new
new Image ();
tileSheet . addEventListener ( 'load' , eventSheetLoaded , false
false );
tileSheet . src = "tanks_sheet.png" ;
function
function eventSheetLoaded () {
startUp ();
}
function
function startUp (){
context . drawImage ( tileSheet , 0 , 0 );
context2 . drawImage ( theCanvas , 32 , 0 , 32 , 32 , 0 , 0 , 32 , 32 );
}
}
< /script>
</head>
</head>
<body>
<body>
<div>
<div>
<canvas
<canvas id= "canvas" width= "256" height= "256" style= "position: absolute;
top: 50px; left: 50px;" > Your browser does not support HTML5 Canvas. </canvas>
</canvas>
Search WWH ::




Custom Search