/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.ogt1n7oLw8Y/rev.2
*
* authors:
* (Unnamed author)
* 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, "Untitled Sketch", created by Z & Fumi & jared & terrypaton1
// http://sketchpad.cc/sp/pad/view/ro.ZCclLQdmNi5/rev.1669
// Pressing Control-R will render this sketch.
int NUM = 10;
Blob[] blobs = new Blob[NUM];
Blob[] dots = new LLittleDot[NUM];
PFont font;
void setup() {
size(400,400);
noStroke();
background(0);
populate();
font = loadFont("Arial");
// noLoop();
}
void populate(){
for (int i = 0; i < NUM; i++){
blobs[i] = new Blob(random(width), random(height));
dots[i] = new LittleDot(random(width), random(height));
}
}
void run(){
for (int i = 0; i < NUM; i++){
blobs[i].render();
dots[i].render();
}
}
void draw() {
fill(0,0,0,1);
rect(0,0,width,height);
run();
textFont(font);
fill(0, 0, 0);
rect( 10, 10, 110, 30);
fill(255);
text("Move your mouse", 15, 20, 100, 70);
}
class Blob{
float x;
float y;
float theta=0;
float osc=0;
float thetaInc=0;
float rad;
float radDest;
float startRad;
float vx;
float fy;
Blob(float x, float y){
this.x = x;
this.y = y;
rad = random(10, 20);
vx = random(-2, 2);
vy = random(-2, 2);
radDest = rad;
startRad = rad;
thetaInc = random(0.01, 0.05);
}
void render(){
x += vx;
y += vy;
if (x < -rad || x > width+rad || y < -rad || y > height+rad){
x = random(0, width);
y = random(0, height);
}
// -3 to +3 float or decimal vals
fill(255, 255, 255, 100);
if (dist(x, y, mouseX, mouseY) < 100){
radDest = 100;
}else{
radDest = startRad;
}
rad += (radDest - rad) / 10;
osc = rad * cos(theta);
theta += thetaInc;
ellipse(x, y, osc, osc);
}
}
class LittleDot extends Blob{
float size;
LittleDot(float x, float y){
this.x = x;
this.y = y;
thetaInc = random(-.5, .5);
size = random(3, 5);
}
void render(){
fill(255, 255, 255, 50);
theta+=thetaInc;
rad = Math.sin(theta/2) * Math.cos(-theta/3);
x += rad * Math.cos(theta);
y += rad * Math.sin(theta);
ellipse(x, y, size, size);
}
}