Js 2次曲線関数
529 ワード
PointOnCubicBezier1(cp , t) {
var tPos = {}
tPos.x = Math.pow((1-t),2)*cp[0].x+2*t*(1-t)*cp[1].x + Math.pow(t,2)*cp[2].x;
tPos.y = Math.pow((1-t),2)*cp[0].y+2*t*(1-t)*cp[1].y + Math.pow(t,2)*cp[2].y;
return tPos;
},
let t1 = 1 ; max = 20
setPoint(){
if(this.t1 < this.max){
this.point = this.PointOnCubicBezier1([this.point,{x:100,y:0},{x:100,y:100}],this.t1/this.max)
this.t1 += 1;
}
}
setInterval(this.setPoint,100)