let points = [];
let sigma, rho, beta;
function setup() {
cnv = createCanvas((w = min(windowWidth, windowHeight) * 0.9), w);
for (let i = 0; i < 5000; i++) {
points[i] = {
x: randomGaussian(0, w / 6),
y: randomGaussian(0, w / 6),
z: randomGaussian(0, w / 6)
};
}
sigma = random(5, 15);
rho = random(15, 40);
beta = random(8 / 3, 20 / 3);
noStroke();
}
function draw() {
translate(w / 2, w / 2);
t = frameCount / 100;
rotate(t / 5);
for (let i = 0; i < points.length; i++) {
let dt = random(0.00001, 0.0002);
let dx = sigma * (points[i].y - points[i].x) * dt;
let dy = (points[i].x * (rho - points[i].z) - points[i].y) * dt;
let dz = (points[i].x * points[i].y - beta * points[i].z) * dt;
points[i].x += dx;
points[i].y += dy;
points[i].z += dz;
push();
x = points[i].x * sin(t / 2) + points[i].z * cos(t / 2);
y = points[i].y * sin(t / 2) + points[i].x * cos(t / 2);
fill(
50 + 50 * sin(points[i].x / 90 - t),
150 + 100 * sin(points[i].y / 90 - t),
200 + 100 * sin(points[i].z / 90 + t / 2),
10
);
circle(x, y, 5);
fill(255, 255, 255, 120);
circle(x, y, 1);
pop();
}
for (let i = 0; i < 20; i++) {
points.shift();
points.push({
x: randomGaussian(0, w / 5),
y: randomGaussian(0, w / 5),
z: randomGaussian(0, w / 5)
});
}
push();
rotate(-t / 5);
noFill();
stroke(255);
rect(-w / 2 + w / 20, -w / 2 + w / 20, w - w / 10, w - w / 10);
pop();
}
function keyPressed() {
if (keyCode === 83) {
save(cnv, "manifold", "png");
}
if (keyCode === 32) {
setup();
draw();
}
console.log(points.length);
}
function windowResized() {
resizeCanvas((w = min(windowWidth, windowHeight) * 0.9), w);
}