xxxxxxxxxx
43
// based on Dan Shiffman's Gist
// https://gist.github.com/shiffman/3b4e3b7bf350eea16589f4f0d019da06
let victors = [];
let factor = 10;
function setup() {
createCanvas(windowWidth, windowHeight);
for (let i = 0; i < 1000; i++) {
victors[i] = createVector(
random(-width * factor, width * factor),
random(-height * factor, height * factor),
random(width)
);
}
}
function draw() {
background(0,50);
for(let i = 0; i < height; i++){
stroke(width-i);
line(0,i,width,i);
}
translate(width / 2, height / 2);
for (let v of victors) {
let x = v.x / v.z;
let y = v.y / v.z;
let d = map(v.z, 0, width, 20, 1);
let mappedVY = map(v.y, 0, height, 100,255);
fill(mappedVY);
noStroke();
circle(x, v.y, d);
v.z -= 1;
if (v.z < 1) {
v.x = random(-width * factor, width * factor);
v.y = random(-height * factor, height * factor);
v.z = random(width);
}
}
}