私はHTML5キャンバス要素(図1参照)を使って円のグループをプロットしようとしています。 enter image description hereHTML5キャンバスの応答がうまくいかない
上記の図は、ブラウザのサイズを変更すると切り取られます。 ブラウザのサイズを変更すると反応がよくなります。
私はそれを反応させるように助けてください。ありがとうございました。
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
canvas.width = window.innerWidth; /// equal to window dimension
canvas.height = window.innerHeight;
var radius = canvas.height/2;
ctx.translate(radius, radius);
radius = radius * 0.9;
drawClock();
function drawClock() {
drawCircle(ctx, radius);
}
function drawCircle(ctx, radius) {
var ang;
var num;
for (num = 1; num <= 40; num++) {
ang = num * Math.PI/20;
ctx.rotate(ang);
ctx.translate(0, -radius * 0.85);
ctx.rotate(-ang);
ctx.beginPath();
ctx.arc(0, 0, radius/20, 0, 2 * Math.PI);
ctx.stroke();
ctx.rotate(ang);
ctx.translate(0, radius * 0.85);
ctx.rotate(-ang);
}
}
#canvas {
display: block;
}
<canvas id="canvas"></canvas>
ありがとうございましたskaa – Trupti