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