-2
我正在使用JavaScript旋轉輪,但我只能通過在while方法中放置alert()(在下面看到(然後在Chrome中單擊忽略連續的消息)。任何幫助或解釋發生的事情將不勝感激。Javascript循環僅適用於如果我執行提醒()
$(document).ready(function() {
var colors = ["#000000", "#FFFFFF", "#FFFFFF", "#FFFFFF"];
var arc = Math.PI/2;
var ctx;
var startAngle = 0;
function drawWheel(startAngle) {
var canvas = document.getElementById("wheel");
if (canvas.getContext) { // Checks for browser support
var outerRadius = 200,
innerRadius = 1;
ctx = canvas.getContext("2d");
ctx.strokeStyle = "black";
ctx.lineWidth = 2;
for(var i = 0; i < 4; i++) { // change to support size of wheel
var angle = startAngle + i * arc;
ctx.fillStyle = colors[i];
ctx.beginPath();
ctx.arc(250, 250, outerRadius, angle, angle + arc, false);
ctx.arc(250, 250, innerRadius, angle + arc, angle, true);
ctx.stroke();
ctx.fill();
}
}
}
function clearWheel() {
var canvas = document.getElementById("wheel");
ctx = canvas.getContext("2d");
ctx.clearRect(0,0,500,500);
}
var i = 0;
while (i<=500) {
// alert(i);
drawWheel(i);
i++;
}
});