xxxxxxxxxx
33
const starColorsHsb = [
[226, 72, 86],
[ 61, 100, 94],
[267, 71, 75],
[309, 60, 93],
[ 3, 81, 82]
];
let stars;
function setup() {
const r = () => random(-700, 700);
createCanvas(400, 400, WEBGL);
colorMode(HSB);
stars = Array.apply(null, Array(1000)).map(() => [
createVector(r(), r(), r()),
int(random(starColorsHsb.length))
]);
}
function draw() {
background(0);
rotateZ(frameCount / 1000);
for (const star of stars) {
push();
const pos = star[0];
const z = cos(frameCount / 50) * 500;
translate(pos.x, pos.y, z + pos.z);
stroke(starColorsHsb[star[1]]);
sphere(1);
pop();
}
}