点の動きはそのままで、動いている図形を点から線に変えたい
このニュアンスがよくわかりませんが、「点と点を線でつなぎたい」ってことでしょうか?
Brownian motion / Examples / Processing.org
そうだとして...
動く前の位置と動いた後の位置はわかっているのですから、(先回りして)動く前後の位置で線を描けばいいでしょう。
Processing
1int a = 4;
2float[] x = new float[a];
3float[] y = new float[a];
4
5void setup() {
6 size(500, 500);
7 frameRate(100);
8 background(0);
9 stroke(255);
10 noFill();
11
12 for (int i = 0; i < a; i++) {
13 x[i] = width/2;
14 y[i] = height/2;
15 }
16}
17
18void draw() {
19 for (int i = 0; i < a; i++) {
20 float x2 = x[i] + random(-5, 5);
21 float y2 = y[i] + random(-5, 5);
22
23 //point(x[i], y[i]);
24 line(x[i], y[i], x2, y2);
25
26 x[i] = x2;
27 y[i] = y2;
28 }
29}
それとも「点の代わりにランダムな長さ・向きの線を描きたい」ってことかな??
Processing
1int a = 4;
2float[] x = new float[a];
3float[] y = new float[a];
4
5void setup() {
6 size(500, 500);
7 frameRate(10);
8 background(0);
9 stroke(255);
10 noFill();
11
12 for (int i = 0; i < a; i++) {
13 x[i] = width/2;
14 y[i] = height/2;
15 }
16}
17
18void draw() {
19 for (int i = 0; i < a; i++) {
20 //point(x[i], y[i]);
21
22 PVector v = PVector.random2D().mult(random(5, 10));
23 line(x[i], y[i], x[i] + v.x, y[i] + v.y);
24 line(x[i], y[i], x[i] - v.x, y[i] - v.y);
25
26 x[i] += random(-5, 5);
27 y[i] += random(-5, 5);
28 }
29}
random2D() / Reference / Processing.org
mult() / Reference / Processing.org