ArrayList<Luciole> lucioles1;
ArrayList<Luciole> lucioles2;
ArrayList<Luciole> lucioles3;
ArrayList<Luciole> lucioles4;
plan1 = loadImage("p1.png");
plan1 = scaleImage(plan1, 4);
plan2 = loadImage("p2.png");
plan2 = scaleImage(plan2, 4);
plan3 = loadImage("p3.png");
plan3 = scaleImage(plan3, 4);
plan4 = loadImage("p4.png");
plan4 = scaleImage(plan4, 4);
plan5 = loadImage("p5.png");
plan5 = scaleImage(plan5, 4);
lucioles1 = genLucioles(3, 1.0);
lucioles2 = genLucioles(10, 3.0);
lucioles3 = genLucioles(100, 4.0);
lucioles4 = genLucioles(300, 8.0);
frame = constrain(frameCount, 0, n_frames);
mX = (mouseX/float(width)) - 0.5;
mY = (mouseY/float(height)) - 0.5;
translate(width-plan5.width+p4_roff-frame*p4_roff/n_frames, 0);
for (int i=0; i<lucioles4.size(); i++) {
lucioles4.get(i).update();
lucioles4.get(i).draw(0);
translate(width-plan3.width+p3_roff-frame*p3_roff/n_frames, 0);
for (int i=0; i<lucioles3.size(); i++) {
lucioles3.get(i).update();
lucioles3.get(i).draw(0);
translate(width-plan2.width+p2_roff-frame*p2_roff/n_frames, 0);
for (int i=0; i<lucioles2.size(); i++) {
lucioles2.get(i).update();
lucioles2.get(i).draw(1);
translate(width-plan1.width+p1_roff-frame*p1_roff/n_frames, 0);
translate(p1_roff-frame*p1_roff/n_frames, 0);
for (int i=0; i<lucioles1.size(); i++) {
lucioles1.get(i).update();
lucioles1.get(i).draw(1);
Luciole(int _x, int _y, int _h_amp, int _v_amp, float _v_h, float _v_v, float _v_b, float _dist) {
h_ang = random(0, TWO_PI);
v_ang = random(0, TWO_PI);
b_ang = random(0, TWO_PI);
x = x_o + round(h_amp/dist * cos(h_ang));
y = y_o + round(v_amp/dist * cos(v_ang));
fill(70, 125-10*b, 240+10*b, 150+b*50);
ellipse(x, y, 1+ceil((6+b*4)/dist), 1+ceil((6+b*4)/dist));
int rad = int((10+4*b)/dist);
fill(70, 110-10*b, 240+10*b, 220+int(30*b/dist));
fill(70, 125-10*b, 240+10*b, 40+int(50*b/dist));
rect(x-rad, y, rad, rad);
rect(x, y-rad, rad, rad);
rect(x+rad, y, rad, rad);
rect(x, y+rad, rad, rad);
PImage scaleImage(PImage image_o, int n) {
PImage result = createImage(w*n, h*n, ARGB);
for (int y=h-1; y>=0; y--) {
for (int x=w-1; x>=0; x--) {
color c = image_o.pixels[w*y+x];
for (int j=0; j<n; j++) {
for (int i=0; i<n; i++) {
result.pixels[w*y*n*n + w*j*n + x*n + i] = c;
ArrayList<Luciole> genLucioles(int n, float dist) {
ArrayList<Luciole> lucioles = new ArrayList<Luciole>();
for (int i=0; i<n; i++) {
int x = int(random(-p1_roff, plan1.width));
int y = int(random(height));
int h_amp = int(random(40));
int v_amp = int(random(40));
float h_v = random(0.01, 0.06);
float v_v = random(0.01, 0.06);
float b_v = random(0.01, 0.04);
lucioles.add(new Luciole(x, y, h_amp, v_amp, h_v, v_v, b_v, dist));