So in this question I was under the impression that using a canvas as a background was faster,or the same speed as using a canvas tag. I currently have a rather bulky script running for a simulator. For some javaScripting reasons I cannot make the menu using JavaScript without detracting from the simulation so I had planned to use HTML to make a menu swipe from the side of the screen. As I was working on that I stumbled on the above link; however when I run the program using the background method it runs much slower. Is there any reason for this, and is there any solution?
Here are the relevant portions of code:
HTML
<html>
<head>
<title>Curtain Sim 2013 </title>
<link href="global.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="fabric.js"></script>
<script type="text/javascript" src="background.js"></script>
<script type="text/javascript" src="savDat.js"></script>
</head>
<div id = "canvas" style="width:100%; height:100%; background: -webkit-canvas(curSim2013); "></div>
<!--<body>
<canvas id="curSim2013">
Your Browser does not support HTML5 </canvas>
</body>-->
</html>
Javascript from main.js which runs it (there are some artifacts commented out from my experimenting)
function init()
{
//Grab the Canvas tag from index.html
canvas = document.getElementById('canvas');
//Create an interface for interacting with canvas in 2D
//context = canvas.getContext('2d');
//var ctx = document.getCSSCanvasContext("2d", "squares", w, h);
//Set the dimensions of the canvas to match the broser window
//Note that global.css helps make this possible
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
context = document.getCSSCanvasContext("2d", "curSim2013", canvas.width, canvas.height);
//Erase the contents of the canvas
context.clearRect(0, 0, canvas.width, canvas.height);
. . .
CSS (nothing much)
html, body {
width: 100%;
height: 100%;
margin: 0px;
}