xxxxxxxxxx
58
var circR, center, negBound, posBound
var count = 0;
var coords = []
function setup() {
createCanvas(500, 500);
circR = width/10;
center = createVector(width/2, height/2);
frameRate(100)
}
function draw() {
noStroke();
makeCoord();
//update position with jitter for each point
coords.forEach(obj => {
motion(obj)
});
//draw background over last paint
background(color(50, 50, 50))
//render the objects
coords.forEach(obj => {
blendMode(SCREEN)
fill(50, 50, 255, random(130, 255))
ellipse(obj.x, obj.y, 2)
})
blendMode(BLEND)
if (coords.length % 500 == 0) {
circR += width/10;
}
}
function motion(obj) {
let xMove = int(random(-2, 2))
let yMove = int(random(-2, 2))
obj.x += xMove;
obj.y += yMove;
}
function makeCoord(){
//borrowed from this nice person: https://editor.p5js.org/zapra/sketches/rjIJR18fT
a = random(0, 2*PI);
r = sqrt(random(0, circR));
x = width/2 + r * cos(a);
y = height / 2 + r * sin(a);
var newDot = createVector(x, y);
coords.push(newDot);
}