スクリプトは Processing 3.0.1 エディターで実行されます。私は達成したい:
- 連続ループ
- for ループの値を 10 に維持します (for ループ内の三角形の新しいセットごとに最も古いセットが置き換えられ、アニメーションが炎の流星のように見えます)
単純な if ステートメントでこれを達成できますか、それとも配列を作成する必要がありますか? 提案を受け付けます。
void setup() {
size(504, 282);
background(0);
}
void draw() {
color from = color(255, 0, 0, 50);
color to = color(255, 255, 0, 300);
color a = lerpColor(from, to, .33);
color b = lerpColor(from, to, .66);
for (int i=0; i<20; i++) {
// 1st Stage
float a1=random(0, 84);
float b1=random(0, 47);
float c1=random(84, 168);
float d1=random(47, 94);
float e1=random(168, 252);
float f1=random(94, 141);
fill(from);
triangle(a1, b1, c1, d1, e1, f1);
// 2nd Stage
float a2=random(84, 168);
float b2=random(47, 94);
float c2=random(168, 252);
float d2=random(94, 141);
float e2=random(252, 336);
float f2=random(141, 188);
fill(a);
triangle(a2, b2, c2, d2, e2, f2);
// 3rd Stage
float a3=random(168, 252);
float b3=random(94, 141);
float c3=random(252, 336);
float d3=random(141, 188);
float e3=random(336, 420);
float f3=random(188, 235);
fill(b);
triangle(a3, b3, c3, d3, e3, f3);
// 4th Stage
float a4=random(252, 336);
float b4=random(141, 188);
float c4=random(336, 420);
float d4=random(188, 235);
float e4=random(420, 504);
float f4=random(235, 282);
fill(to);
triangle(a4, b4, c4, d4, e4, f4);
noStroke();
}
//saveFrame("####.png");
}