方法はたくさんありますが、公式サンプルを応用した例。
Linear Interpolation / Examples / Processing.org
Processing
1float x;
2float y;
3
4void setup() {
5 size(640, 360);
6 noStroke();
7
8 x = random(width);
9 y = random(height);
10}
11
12void draw() {
13 background(51);
14
15 //x = lerp(x, mouseX, 0.05);
16 //y = lerp(y, mouseY, 0.05);
17 x = lerp(x, width / 2, 0.05);
18 y = lerp(y, height / 2, 0.05);
19
20 fill(255);
21 stroke(255);
22 ellipse(x, y, 66, 66);
23}
24
25void mousePressed() {
26 x = random(width);
27 y = random(height);
28}