キャンバスで作業しているときに問題が発生しました。以下のコードを参照してください。
HTML
<canvas id="canvas" width="400" height="400"></canvas>
<input id="but" type="button" value="clear canvas" onclick="ClearCanvas()">
JS
can = document.getElementById('canvas');
ctx = can.getContext("2d");
ctx.fillStyle = 'rgb(205,190,245)';
ctx.fillRect(0, 0, can.width, can.height);
ctx.scale(0.4, 0.4);
ctx.fillStyle = 'rgb(105,180,235)';
ctx.fillRect(0, 0, can.width, can.height);
$("#but").click(function()
{
var ctx = document.getElementById('canvas').getContext("2d");
ctx.scale(1, 1);
ctx.clearRect(0, 0, can.width, can.height);
});
「キャンバスをクリア」ボタンをクリックしても、キャンバス全体がクリアされません。スケーリングされた部分をクリアしているだけです。スケーリングした後にキャンバス全体をクリアするにはどうすればよいですか?
注:FFでは問題ありません。