- <!DOCTYPE>
- <head>
- <meta charset="utf-8">
- </head>
- <body>
- <div id="gameArea"><canvas id="sameCanvas"></canvas></div>
- <script>
- var gameHeight=window.innerHeight;
- var gameWidth =window.innerWidth ;
- var gameArea =document.getElementById("gameArea") ;
- var gameCanvas=document.getElementById("gameCanvas");
- gameArea.style.height=gameHeight;
- gameArea.style.width=gameWidth;
- gameCanvas.height=gameHeight;
- gameCanvas.width=gameWidth;
- var ctx=gameCanvas.getContext("2d");
- ctx.fillStyle="rgb(0,0,0)";
- ctx.fillRect(0,0,gameWidth,gameHeight);
- </script>
- </body>
複製代碼 |