65,210
社区成员
发帖
与我相关
我的任务
分享
//哪位大侠能帮我看看下面这段代码的思想?主要是x,y的赋值和cos ,sin??
var angel = parseFloat(xmlHttp.responseText);
rate = angel / 360 *100;
if((angel > 0.0) && (angel<=90.0))
{
x = 150 + 150*Math.cos((angel)*6.283/360);
y = 150 - 150*Math.sin((angel)*6.283/360);
}
else if((angel>90.0)&&(angel<=180.0))
{
x = 150 - 150*Math.cos((180-angel)*6.283/360);
y = 150 - 150*Math.sin((180-angel)*6.283/360);
}
else if((angel >180.0)&&(angel<=270.0))
{
x = 150 - 150*Math.cos((angel-180)*6.283/360);
y = 150 + 150*Math.sin((angel-180)*6.283/360);
}
else
{
x = 150 + 150*Math.sin((angel - 270)*6.283/360);
y = 150 + 150*Math.cos((angel - 270)*6.283/360);
}
if(angel <= 180.0)
{
fm.setAttribute("d","M 150 150 L 300 150 A 150 150 0 0 0 "+x.toString()+" "+y.toString()+" "+"L 150 150 z");
sm.setAttribute("d","M 150 150 L "+x.toString()+" "+y.toString()+" "+"A 150 150 0 1 0 300 150 L 150 150 z");
tm.firstChild.data = "disk-rate:"+rate.toString()+"%";
}
else
{
fm.setAttribute("d","M 150 150 L 300 150 A 150 150 0 1 0 "+x.toString()+" "+y.toString()+" "+"L 150 150 z");
sm.setAttribute("d","M 150 150 L "+x.toString()+" "+y.toString()+" "+"A 150 150 0 0 0 300 150 L 150 150 z");
tm.firstChild.data = "disk-rate:"+rate.toString()+"%";
}
}
}