Hi.
I found such lovely sketches on Twitter like this one below from @KomaTebe, but I can’t translate it into the usual (not shorthand) code.
Could anyone do this?

Thank you for trying, but this code does not have the same outcome.
I only got this far.

let f = 0;
function setup() {
createCanvas((W = 400), W, WEBGL);
}
function draw() {
background(0);
noStroke();
for (
[-W, 0].map((a) => pointLight([W], 0, a, W)), i = 0;
i < TAU;
i += PI / 2048
) {
push();
rotateY(i - f);
let x = 120 * sin(tan(i));
let y = 50 * tan(atan(tan(i + f)));
let z = 120 * cos(tan(i));
translate(x, y, z);
sphere(3 * cos(i + f), 12);
pop();
}
f += 0.01;
}

I managed this translation until now. But I still can’t simplify the following line
arr.map((a) => pointLight(c, 0, a, width));
to a common function. Can you?

let f = 0;
function setup() {
createCanvas(400, 400, WEBGL);
}
function draw() {
background(0);
noStroke();
let c = color(255);
let arr = [-width, 0];
arr.map((a) => pointLight(c, 0, a, width));
for (i = 0; i < TAU; i += PI / 2048) {
push();
rotateY(i - f);
let ti = tan(i);
let tif = tan(i + f);
let x = 120 * sin(ti);
let atif = atan(tif);
let y = 50 * tan(atif);
let z = 120 * cos(ti);
translate(x, y, z);
sphere(3 * cos(i + f), 12);
pop();
}
f += 0.01;
}

let f = 0;
let W = 400;
function setup() {
createCanvas(W, W, WEBGL);
}
function draw() {
background(0);
noStroke();
pointLight(255,255,255, 0, -W, width);
pointLight(255,255,255, 0, 0, width);
for (i = 0; i < TAU; i += PI / 2048) {
push();
rotateY(i - f);
let ti = tan(i);
let tif = tan(i + f);
let x = 120 * sin(ti);
let atif = atan(tif);
let y = 50 * tan(atif);
let z = 120 * cos(ti);
translate(x, y, z);
sphere(3 * cos(i + f), 12);
pop();
}
f += 0.01;
}

Oh, thanks!
So the .map() function iterates through the array [-400, 0].
Thus I changed the line to:

setPointLight(c, arr);

and added the function:

function setPointLight(c, arr) {
for ( let i = 0; i < arr.length; i++) pointLight(c, 0, arr[i], width)
}

And that’s it.
But still… to say that I really understand the code?
How does one even come up with a piece like that?
You need a real good mathematical mind.

doesn’t really matter, but actually that are only two instructions for this predefined array with two elements. Imho not necassary to do a loop for it.

To be honest, that’s not really any fancy high-level math, but rather just simple trigonometry…
The real point is, that someone thinks about what creative things can be done with it.