Saltearse al contenido

Math + Art = Simulación

Animación de: https://x.com/yuruyurau

/*
Código de https://x.com/yuruyurau
a=(x,y,d=mag(k=(4+sin(y*2-t)*3)*cos(x/29),e=y/8-13))=>point((q=3*sin(k*2)+.3/k+sin(y/25)*k*(9+4*sin(e*9-d*3+t*2)))+30*cos(c=d-t)+200,q*sin(c)+d*39-220)
t=0,draw=$=>{t||createCanvas(w=400,w);background(9).stroke(w,96);for(t+=PI/240,i=1e4;i--;)a(i,i/235)}
*/
let time = 0;
function setup() {
createCanvas(600, 600);
stroke(255, 96);
}
function draw() {
background(9);
time += PI / 240;
for (let i = 10000; i > 0; i--) {
drawPoint(i, i / 235);
}
}
function drawPoint(x, y) {
const k = (4 + sin(y * 2 - time) * 3) * cos(x / 29);
const e = y / 8 - 13;
const distance = mag(k, e);
const angle = distance - time;
const q = 3 * sin(k * 2) + 0.3 / k + sin(y / 25) * k * (9 + 4 * sin(e * 9 - distance * 3 + time * 2));
const xPos = q + 30 * cos(angle) + 300;
const yPos = q * sin(angle) + distance * 39 - 120;
point(xPos, yPos);
}
function keyPressed(){
console.log(frameRate());
}