我正在制作一些演示网页,作为作品集的一部分,向潜在的雇主展示。
其中一页是“等离子球”中等离子弧的模拟,然后旋转“等离子球”以 360 度查看“弧”。
仅当我在每次重绘后放置“警报”,然后在脚本运行时取消警报时,每次旋转的弧线重绘才有效。没有警报,什么也不会发生。
有人对此有解释/解决方案吗?这是重绘函数:
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();
}
}