function setup(p8g) {
p8g.background(255);
const {width, height} = p8g;
const {random, sin, cos, PI} = Math;
const TAU = 2 * PI;
const pos = new Float32Array(totalParticles*5);
const rgb = new Uint8Array(pos.buffer);
for (let j = 0; j < totalParticles; j++) {
const idx = j*5;
const phi = TAU * random();
const r = 1 + random() * 10 + random() * 10;
pos[idx] = r * sin(phi);
pos[idx+1] = r * cos(phi);
pos[idx+2] = random() * width;
pos[idx+3] = random() * height;
const RGB_idx = idx * 4 + (4*4);
const t = j*256/totalParticles;
rgb[RGB_idx] = (1 + sin(t*TAU)) * 127.5 | 0
rgb[RGB_idx+1] = (1 + sin((t + 2/3)*TAU)) * 127.5 | 0
rgb[RGB_idx+2] = (1 + sin((t + 1/3)*TAU)) * 127.5 | 0
}
return [pos, rgb];
}