xxxxxxxxxx
51
//https://www.youtube.com/watch?v=8fgJ6i96fTY
let pts;
function setup() {
createCanvas(800, 800, WEBGL);
angleMode(DEGREES);
stroke(220);
background(20);
strokeWeight(4);
pts = [];
// for (let off = -width / 3; off < width * 0.66; off += width*.2) {
let off = width / 2;
let zoff = random(-width/3, width/3);
for (theta = 0; theta < 60; theta++) {
for (let phi = 0; phi < 360; phi += 2) {
let r = ((70 * pow(abs(sin((phi * 8) / 2)), 1) + 225) * theta) / 60;
let x = off + r * cos(phi);
let y = off + r * sin(phi);
let z = zoff +
vShape(350, r / 100, 0.8, 0.15) -
200 +
perturbation(1.5, r / 100, 12, phi);
pts.push({ x: x, y: y, z: z, c: random(40,255) });
}
}
// }
}
function draw() {
background(20);
orbitControl(4, 4);
rotateX(80);
beginShape(POINTS);
for (let p of pts) {
stroke(p.c)
vertex(p.x, p.y, p.z);
}
endShape();
}
function vShape(A, r, a, b) {
return A * pow(Math.E, -b * pow(abs(r), 1.5)) * pow(abs(r), a);
}
function perturbation(A, r, p, angle) {
return 1 + A * pow(r, 2) * sin(p * angle);
}