xxxxxxxxxx
47
let ox, oy;
let vx = 2.5;
let vy = 1.2;
let size = 5;
let lastTime;
function setup() {
createCanvas(400, 400);
background(5);
//noStroke();
stroke(255);
strokeWeight(size);
ox = width/2;
oy = height/2;
lastTime = millis();
}
function ppong(a, b) {
return b * abs(fract(a / (2 * b)) * 2 - 1);
}
function draw() {
background(5, 20);
let t = millis() * 0.001 * 50;
randomSeed(0);
for (let i = 0; i < 1000; i++) {
ox = random(width);
oy = random(height);
vx = random(-1, 1);
vy = random(-1, 1);
let x = ppong(ox + vx * t, width);
let y = ppong(oy + vy * t, height);
point(x, y);
//circle(x, y, size);
}
if (millis() - lastTime > 1000) {
print("FPS: " + frameRate());
lastTime += 1000;
}
}