圆形轨迹函数

2017-10-08  本文已影响0人  邱帅123

# 圆形轨迹


function yuan(obj,x,y,s){

var num = 0;

setInterval(function(){

var a = Math.sin(num*Math.PI/180)*s;

console.log("a:"+a)

var b = Math.cos(num*Math.PI/180)*s;

console.log("b:"+b)

obj.style.top=y+a+"px";

obj.style.left=(x-250)+b+"px";

num++;

if (num>360)

{

num=0

}

}, 50)

}


上一篇 下一篇

猜你喜欢

热点阅读