blendModeのADDを使う

Processing3.0が必要。 ADDを使うときは、背景を暗めの色にして、それから明るめの色を足していく。
/** * blendMode Test * * @author aa_debdeb * @date 2016/01/20 * * Processing 3.0 is required for this sketch. */ ArrayList<Field> fields; void setup(){ size(500, 500); frameRate(30); smooth(); fields = new ArrayList<Field>(); for(int i = 0; i < 100; i++){ fields.add(new Field()); } } void draw(){ blendMode(ADD); background(0); for(Field field: fields){ field.display(); field.update(); } } class Field{ PVector topLeft; PVector size; PVector pos; PVector vel; int c; float radious; Field(){ size = new PVector(map(random(1), 0, 1, 30, 100), map(random(1), 0, 1, 30, 100)); topLeft = new PVector(random(width - size.x), random(height - size.y)); pos = new PVector(random(size.x), random(size.y)); vel = new PVector(map(random(1), 0, 1, -1, 1), map(random(1), 0, 1, -1, 1)); vel.normalize(); vel.mult(3); c = color(random(255), random(255), random(255)); radious = map(random(1), 0, 1, 5, 15); } void display(){ pushMatrix(); translate(topLeft.x, topLeft.y); noFill(); stroke(c); strokeWeight(1); rect(0, 0, size.x, size.y); fill(c); noStroke(); ellipse(pos.x, pos.y, radious * 2, radious * 2); popMatrix(); } void update(){ pos.add(vel); if(pos.x <= radious){ pos.x = radious; vel.x *= -1; } if(pos.x >= size.x - radious){ pos.x = size.x - radious; vel.x *= -1; } if(pos.y <= radious){ pos.y = radious; vel.y *= -1; } if(pos.y >= size.y - radious){ pos.y = size.y - radious; vel.y *= -1; } } }