私はcanvas要素を持っています:
<canvas id="canvas" width="100" height="100"></canvas>
そして、キャンバスをフルスクリーンにするためのJavaScript:
var canvas, ctx, w, h;
function start() {
canvas = $("#canvas")[0];
ctx = canvas.getContext("2d");
w = $('body').innerWidth();
$("#canvas").width(w);
$("#canvas").height(w);
w = $("#canvas").width();
h = $("#canvas").height();
if(typeof game_loop != "undefined") clearInterval(game_loop);
game_loop = setInterval(paint, 60);
}
function paint() {
ctx.fillStyle = "white";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "blue";
ctx.strokeRect(0, 0, 50, 50);
}
なぜ私が1つの大きな正方形を取得しないのかわかりません50x50
。手伝ってくれますか?