xxxxxxxxxx
// By Roni Kaufman
// mod by Richard Bourne
let kMax;
let step;
let n = 9; // number of blobs
let radius = 0.7; // diameter of the circle
let inter = .8; // difference between the sizes of two blobs
let maxNoise = 9;
let lapse = 0; // mouse timer
let colorOff = 12;
let noiseProg = (x) => (x);
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 255);
angleMode(DEGREES);
noFill();
kMax = 3;
step = 4;
noStroke();
}
function draw() {
blendMode(BLEND);
background(255);
blendMode(DIFFERENCE);
let t = frameCount;
for (let i = n; i > 0; i--) {
let size = radius + i * inter;
let k, noisiness;
k = kMax * sqrt(i/n);
noisiness = maxNoise * noiseProg(i/n);
fill(t%255, 255, 255)
blob(size, width/2, height/2, k, t - i * step, noisiness);
fill((t+20)%255, 255, 255)
blob(size, width/4, height/3, k, t - i * step + colorOff, noisiness);
fill((t+40)%255,255,255)
blob(size, width/2, height/2, k, t - i * step + 2*colorOff, noisiness);
}
}
function blob(size, xCenter, yCenter, k, t, noisiness) {
beginShape();
let angleStep = 360 / 14;
for (let theta = 0; theta <= 360 + 3 * angleStep; theta += angleStep) {
//let r1 = cos(theta)+1;
//let r2 = sin(theta)+1;
let alpha = 7;
let r = (size + ((tan((theta + t)*alpha) + 1)/4 + (sin((theta + t)*alpha) + 1)/2) * noisiness) * 12;
let x = xCenter + r * cos(theta);
let y = yCenter + r * sin(theta);
curveVertex(x, y);
}
endShape();
}
function mousePressed(){
// prevents mouse press from registering twice
if (millis() - lapse > 500){
save('pix.jpg');
lapse = millis();
}
}