作为展示给潜在雇主的组合部分,我正在制作一些演示网页。
其中一个页面模拟了一个“等离子球”中的等离子弧,并旋转360度以查看“弧”。
只有在每次旋转后重绘弧线时,如果我在重绘后加上“alert”,然后在脚本运行时取消警报,它才能正常工作。没有警报,什么也不会发生。
有人能解释或解决这个问题吗?以下是重绘函数:
function reDraw(yAngle) //work in progress - redraw the arc through 360 degrees to see the path
{
var xCs;
var yCs;
for(degrees=10; degrees<360; degrees+=1)//spin sphere through 360 degrees
{
context1 = document.getElementById("canvas1").getContext("2d");
context1.clearRect(0,0,600,600);
radialGrad(1,'canvas1',300,300,300,300,300,0,0,1,colour1,colour2,0,0,600,600);
firstMove=true;
for(moves=0; moves<axisMove; moves++)
{
if(firstMove)//start at centre of sphere for each re-draw
{
xCs=300;
yCs=300;
firstMove=false;
}
context1.beginPath();
context1.moveTo(xCs,yCs);
spinAngle=(degrees/180*Math.PI);
//we are spinning in the X-Z plane so resolve X-Z moves only - retrieve each positive or negative move from the axis move arrays
xCs=xCs+(zCStep[moves]*Math.sin(spinAngle))+(xCStep[moves]*Math.cos(spinAngle));
yCs=yCs+yCStep[moves];
context1.lineTo(xCs,yCs);
context1.shadowBlur=2;
context1.shadowColor="grey";
context1.strokeStyle="white";
context1.stroke();
}
alert();
}
}