xxxxxxxxxx
63
/*
Inspiration:
https://www.instagram.com/p/B2ASNwwnkf3/
Context:
https://rtp.media.mit.edu/
*/
let caneva_size = 900;
let center = caneva_size / 2;
let circle_size = 6;
let r = 0; // rotations counter
function setup() {
// frameRate(6);
createCanvas(caneva_size, caneva_size);
background(0);
noStroke();
}
function draw() {
//sets the origin to the center
translate(center*0.9, center*1.1);
let rot_div = 10;
rotate(PI - 4*sqrt(r+1) * TWO_PI / rot_div);
let thick_noise = map(noise(r), 0,1, 0.9,1.5);
// parabola fade loop
for (let offset = 0; offset < center/6; offset += circle_size) {
// basic parabola
let paralength = center / 9;
for (let x = -paralength; x < paralength; x += 1) {
let brightness = map(abs(x), 0,paralength, 255, 0);
brightness -= map(offset, 0,center/3, 0,255);
brightness *= map(noise(offset), 0,1, 0.5,2);
fill(255, brightness/5);
// parabola equation: y = -x²/thickness + offset
let spiral = map(r , 0,rot_div , -0.15, 0.01) * center;
offset = center/3 - offset + spiral;
let thickness = (paralength/4) * thick_noise;
let y = -x*x / thickness + offset;
ellipse(x, y, circle_size, circle_size * 4);
}
}
r++; // rotation
if (r >= rot_div*6) {
print("done");
noLoop();
}
}