xxxxxxxxxx
83
let blobs = [];
let numberOfBlobs = 25;
let phase = 0;
let zoff = 0;
let noiseMax = 1.0;
function setup() {
createCanvas(windowWidth, windowHeight);
for (i = 0; i < numberOfBlobs; i++){
blobs.push(new Blob(random(0, width/2),
random(0, height/2),
random(width),
random(height),
random(0, 255),
random(0, 255),
random(0, 255),
random(0, 255),
random(0, 1)
));
}
}
function draw() {
//noLoop();
background(147, 155, 201);
noStroke();
fill(25, 50, 150, 100);
//noiseMax = noise(noiseMax);
//noiseMax += 0.01;
for (i = 0; i < blobs.length; i++) {
blobs[i].update();
}
}
class Blob {
constructor(x, y, xpos, ypos, r, g, b, a, noiseVal) {
this.x = x;
this.y = y;
this.xpos = xpos;
this.ypos = ypos;
this.r = r;
this.g = g;
this.b = b;
this.a = a;
this.noiseVal = noiseVal;
}
update() {
push();
translate(this.xpos, this.ypos);
fill(this.r, this.g, this.b, this.a);
beginShape();
for (let a = 0; a < TWO_PI; a += radians(5)) {
let xoff = map(cos(a + phase), -1, 1, 0, map(noise(this.noiseVal), 0, 1, 0, noiseMax));
let yoff = map(sin(a + phase), -1, 1, 0, map(noise(this.noiseVal), 0, 1, 0, noiseMax));
//let xoff = map(cos(a + phase), -1, 1, 0, noiseMax);
//let yoff = map(sin(a + phase), -1, 1, 0, noiseMax);
//let xoff = map(cos(a + phase), -1, 1, 0, noise(noiseMax));
//let yoff = map(sin(a + phase), -1, 1, 0, noise(noiseMax));
let r = map(noise(xoff, yoff, zoff), 0, 1, 5, height / 4);
let x = r * cos(a);
let y = r * sin(a);
vertex(x, y);
}
endShape(CLOSE);
pop();
phase += random(0.0001, 0.0005);
zoff += 0.001;
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}