Hello,
I am trying to load a background image onto my canvas without having it show up on the page itself.
So I've defined a bg parameter and applied the local resource to it, and then tried to use the drawImage method to apply it to the canvas, but nothing seems to happen. Can anyone tell me what am I doing wrong?
Here's the code I am using:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<script>
var boardTiles;
// main;
// function main()
// {
//load the board bg image
var bg;
bg.src='board.png';
//display the board image on the canvas
var c=document.getElementById("gameCanvas");
var gameBoard=c.getContext("2d");
gameBoard.drawImage(bg,0,0);
// }
</script>
</head>
<body>
<canvas id="gameCanvas" width="1280" height="720" style="border:1px solid #c3c3c3;">
Your browser does not support HTML5.
</canvas>
</body>
</html>