/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://dflab.sketchpad.cc/sp/pad/view/ro.$JVOrqHG5Cd/rev.555
*
* authors:
* Pedro Soares
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
float px[];
float py[];
int num_particles = 320;
void setup () {
size (800,700);
background (125, 0, 125);
frameRate (50);
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);
}
}
float a = 0;
float b = 0;
float d = 0;
float c = 300;
void draw () {
background (125, 0, 125);
fill (120);
strokeWeight (2);
ellipse (mouseX, mouseY, 50, 50);
fill (255,0,0);
ellipse (mouseX, mouseY, 20, 20);
stroke (255, 200,0);
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) < 40) {
vx = (px[i] - mouseX);
vy = (py[i] - mouseY);
px[i] = px[i] + vx;
py[i] = py[i] + vy;
}
ellipse (px[i], py[i], 5, 5);
}
if (mousePressed ==true){
noStroke();
fill (255,255,0);
ellipse (mouseX, mouseY, a, a);
fill (255,125,0);
ellipse (mouseX, mouseY, -30+a, -30+a);
fill (255,0,0);
ellipse (mouseX, mouseY, -140+a, -140+a);
stroke (255,255,0);
strokeWeight (20);
noFill ();
ellipse (mouseX, mouseY, 15+b, 15+b);
strokeWeight (5);
ellipse (mouseX, mouseY, -10+d, -10+d);
strokeWeight (15);
stroke (255, 180, 0, c);
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) < 10) {
vx = (px[i] - mouseX);
vy = (py[i] - mouseY);
px[i] = px[i] + vx;
py[i] = py[i] + vy;
}
ellipse (px[i], py[i], 5, 5);
}
c = c-2
a = a+19;
b = b+26;
d = d+24;
}
else {
a = 0;
b = 0;
d = 0;
c = 300;
stroke (0);
}
}