array_PVector_ellipse05
int num = 1000; PVector[] pos; PVector[] vel; color[] c; void setup() { size(500, 500); colorMode(HSB, 360, 100, 100, 100); background(0, 0, 100); noStroke(); mousePressed(); } void draw() { fill(0, 0, 100, 10); rect(0, 0, width, height); for (int i=0; i < num; i++) { pos[i].add(vel[i]); fill(c[i]); ellipse(pos[i].x, pos[i].y, i%100, i%100); if (pos[i].x < 0 || pos[i].x > width) { vel[i].x= - vel[i].x; } if (pos[i].y <0 || pos[i].y >height) { vel[i].y= - vel[i].y; } } } void mousePressed() { pos = new PVector[num]; vel = new PVector[num]; c = new color[num]; for (int i =0; i < num; i ++) { pos[i] = new PVector( random(width), random(height)); vel[i] = new PVector( random(-10, 10), random(-10, 10)); c[i] = color(random(80, 100), i%100, i%100, i%100); } }
メディア芸術祭の内覧会に出席するため東京に出張.実家での作業.移動で疲れたこともあって,昨日のコードの色を変え,Y軸でも跳ね返りをつけて,mousePressed
でリセットを設定.ちょっとした修正だけど,修正しただけ,動きに反映されるので面白い.