xxxxxxxxxx
56
let r = 150;
let a = 0;
let numRings = 20;
let numPoints = 150;
let points = [];
let rounds = 1;
function setup() {
createCanvas(600, 600);
stroke(255);
fill(255);
colorMode(HSB);
createStars();
}
function draw() {
background(0);
translate(width/2, height/2);
for(let i = points.length-1 ; i >= 0 ; i--){
stroke(points[i].color, 255, 255);
point(points[i].x, points[i].y);
points[i].y = points[i].y + points[i].vel;
if(points[i].y > height/2){
points.splice(i, 1);
}
};
if(points.length == 0){
createStars();
}
}
function createStars(){
for (let j = 0; j < numRings; j++) {
let color = map(j, 0, 10, 10, 255);
let offsetX = j * map(noise(rounds), 0, 1, -5, 5);
let offsetY = j * map(noise(rounds-1), 0, 1, -5, 5);
for (let i = 0; i < numPoints; i++) {
r = r + random(-5, 5);
let x = r * sin(a);
let y = r * cos(a);
points.push({x: x + offsetX, y: y + offsetY, color, vel: random(2, 5)});
a += i;
}
}
rounds++;
}