> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://dflab.sketchpad.cc/sp/pad/view/ro.6b63cWKeRXC/rev.231
 * 
 * authors: 
 *   adriana barros

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// This sketch builds on a prior work, "AnaRitaFilipe - 02 -  Elipses a movimentarem-se", created by anaritaf
// http://dflab.sketchpad.cc/sp/pad/view/ro.9IXBGI7ifMY0pm/rev.173



// as instruções que estiverem dentro desta função setup() 
// correm uma vez quando o programa arranca



float px[];
float py[];
 
int num_particles = 3000;

void setup() {  
    
    // tamanho da tela
    size(800, 300); 

    // cor de fundo
    background(130,15,90);
    
    px = new float[num_particles];
    py = new float[num_particles];
    
    for (int i = 0; i < num_particles; i++) {
        px[i] = random (width);
        py[i] = random (height);
    }
} 

// as instruções que estiverem dentro desta função draw
// são executadas a cada novo frame

void draw() {
     //background(100,0,30);
    
    for (int i = 0; i < num_particles; i = i+1) {
        px[i] = constrain (px[i] + random (-3, 5), 0, width);
        py[i] = constrain (py[i] + random (-4, 8), 0, height);
        
        if (dist (px[i], py[i], mouseX, mouseY) < 90) {
            vx = (px[i] - mouseX);
            vy = (py[i] - mouseY);
            
            px[i] = px[i] + vx;
            py[i] = py[i] + vy;
        }
fill(0,150,150);
        ellipse (px[i], py[i], 50, 50);
    }

 for (int i = 0; i < num_particles; i = i+1) {
        px[i] = constrain (px[i] + random (-20, 5), 0, width);
        py[i] = constrain (py[i] + random (-20, 5), 0, height);
        
        if (dist (px[i], py[i], mouseX, mouseY) < 0) {
            vx = (px[i] - mouseX);
            vy = (py[i] - mouseY);
            
            px[i] = px[i] + vx;
            py[i] = py[i] + vy;
        }
fill(160,20,200);
        ellipse (px[i], py[i], 30, 10);
    }

for (int i = 0; i < num_particles; i = i+1) {
        px[i] = constrain (px[i] + random (-5, 5), 0, width);
        py[i] = constrain (py[i] + random (-5, 5), 0, height);
        
        if (dist (px[i], py[i], mouseX, mouseY) < 70) {
            vx = (px[i] - mouseX);
            vy = (py[i] - mouseY);
            
            px[i] = px[i] + vx;
            py[i] = py[i] + vy;
        }
fill(100,260,235);
        ellipse (px[i], py[i], 13, 13);
    }

}