xxxxxxxxxx
// a quick & hellish sketch for fun. prevent the blob from falling into the black hole.
// by la-krok
let kMax;
let step;
let n = 3; // number of blobs
let radius = 8; // diameter of the circle
let inter = 0.3; // difference between the sizes of two blobs
let maxNoise = 100;
let lapse = 100; // timer
let noiseProg = (x) => (x);
let bubble;
function setup() {
createCanvas(400, 400);
bubble = 100;
// colorMode(HSB, 1);
angleMode(DEGREES);
noFill();
kMax = random(0.6, 1.0);
step = 0.01;
noStroke();
}
function draw() {
let t = frameCount/100;
for (let i = n; i > 0; i--) {
let alpha = pow(1 - noiseProg(i / n), 2);
let size = radius + i * inter;
let k = kMax * sqrt(i/n);
let noisiness = maxNoise * noiseProg(i / n);
background(50, 4, 8);
blendMode(BLEND);
bubble = bubble + 1;
fill(1,2,1);
ellipse(200, 360, 150, 35);
//BLOB1
erase();
fill(255, 0, 0, alpha*255);
blob(size, width/2, bubble, k, t - i * step, noisiness);
noErase();
//BLOB2
fill(0, 255, 0, alpha*255);
blob(size, width/2, bubble, k, t - i * step + 1, noisiness);
noErase();
//BLOB3
fill(0, 0, 255, alpha*255);
blob(size, width/2, bubble, k, t - i * step + 2, noisiness);
noErase();
if (mouseIsPressed) {
bubble = bubble - 2;
}
fill(50, 4, 8);
rect(125, 377, 150, 30);
}
function blob(size, xCenter, yCenter, k, t, noisiness) {
beginShape();
let angleStep = 360 / 12;
for (let theta = 0; theta <= 360 + 2 * angleStep; theta += angleStep) {
let r1, r2;
r1 = cos(theta)+1;
r2 = sin(theta)+1;
let r = size + noise(k * r1, k * r2, t) * noisiness;
let x = xCenter + r * cos(theta);
let y = yCenter + r * sin(theta);
curveVertex(x, y);
}
endShape();
}
}