/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.tOsdEXk-9r8/rev.1998
*
* authors:
* alexsmith540
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// Pressing Control-R will render this sketch.
ArrayList bubbles;
Bubble bub;
void setup() { // this is run once.
bubbles = new ArrayList;
for(i=0;i<=60;i++){
bubbles.add(new Bubble());
}
// set the background color
background(255);
// canvas size (Variable aren't evaluated. Integers only, please.)
size(600, 600);
// smooth edges
smooth();
// limit the number of frames per second
frameRate(30);
// set the width of the line.
}
void draw() { // this is run repeatedly.
background(0);
int sz = bubbles.size()-1;
for(i=0;i<sz;i++){
bub = bubbles.get(i);
bub.run();
}
}
class Bubble{
float sc;
color coll;
float rstart1;
float rstart2;
float randnum,randnum2;
float speedrate;
int ttype;
Bubble(){
speedrate = random(0,5);
sc = 1;
ttype = floor(random(5,500)*100) % 2 == 0 ? 0 : 1;
console.log(ttype);
coll = color(random(0,255),random(0,255),random(0,255));
rstart1 = random(-200,200);
rstart2 = random(-200,200);
randnum = random(50,300);
randnum2 = random(50,300);
}
void run(){
sc += ttype == 0 ? random(-0.0001,-0.000000001) : random(0.0001,0.000000001);
randnum2 += sin(random(0,1))*speedrate;
randnum += sin(random(0,1))*speedrate;
rstart1 += ttype == 0 ? random(0.05,0.10) : random(0.11,0.40);
rstart2 += ttype == 0 ? random(0.05,0.10) : random(0.11,0.40);
rstart1 = randnum > 400 ? rstart1 = random(-200,200) : rstart1;
rstart2 = randnum2 > 400 ? rstart1 = random(-200,200) : rstart2;
randnum = randnum > 400 ? random(50,300) : randnum;
randnum2 = randnum2 > 400 ? random(50,300) : randnum2;
//randnum += cos(random(0,1)*400) > 0 ? cos(random(0,1)*400) : ( randnum > 50 ? cos(random(0,1)*400)*10 : 3 ) ;
strokeWeight(randnum*0.003);
fill(coll,abs(randnum*0.3));
pushMatrix();
//scale(sc);
translate(width/2, height/2);
rotate(degrees(sc));
ellipse(rstart1,rstart2,randnum,randnum2);
popMatrix();
}
}