formula
nowValue += (targetValue - nowValue) * 0.03;
現在の値 += (目標値 - 現在の値) * イージング係数
目的地付近に近づくにつれ減速するデモです。
(本当はちゃんとx:0の左端から発進するんですがなぜか録画うまくいかず..)
Processingのコードです。
sample
float nowPos = 0;
float tagetPos = 500;
void setup(){
size(500,500);
}
void draw(){
background(0);
nowPos += (tagetPos - nowPos) * 0.03; // ここ!
ellipse(nowPos, 200, 30, 30);
}