回答編集履歴
1
それとも「点の代わりにランダムな長さ・向きの線を描きたい」ってことかな??
test
CHANGED
@@ -37,3 +37,40 @@
|
|
37
37
|
}
|
38
38
|
}
|
39
39
|
```
|
40
|
+
|
41
|
+
---
|
42
|
+
|
43
|
+
それとも「点の代わりにランダムな長さ・向きの線を描きたい」ってことかな??
|
44
|
+
```Processing
|
45
|
+
int a = 4;
|
46
|
+
float[] x = new float[a];
|
47
|
+
float[] y = new float[a];
|
48
|
+
|
49
|
+
void setup() {
|
50
|
+
size(500, 500);
|
51
|
+
frameRate(10);
|
52
|
+
background(0);
|
53
|
+
stroke(255);
|
54
|
+
noFill();
|
55
|
+
|
56
|
+
for (int i = 0; i < a; i++) {
|
57
|
+
x[i] = width/2;
|
58
|
+
y[i] = height/2;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
void draw() {
|
63
|
+
for (int i = 0; i < a; i++) {
|
64
|
+
//point(x[i], y[i]);
|
65
|
+
|
66
|
+
PVector v = PVector.random2D().mult(random(5, 10));
|
67
|
+
line(x[i], y[i], x[i] + v.x, y[i] + v.y);
|
68
|
+
line(x[i], y[i], x[i] - v.x, y[i] - v.y);
|
69
|
+
|
70
|
+
x[i] += random(-5, 5);
|
71
|
+
y[i] += random(-5, 5);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
```
|
75
|
+
[random2D() / Reference / Processing.org](https://processing.org/reference/PVector_random2D_.html)
|
76
|
+
[mult() / Reference / Processing.org](https://processing.org/reference/PVector_mult_.html)
|