xxxxxxxxxx
lines = []
n = 200;
function setup() {
colorMode(HSB)
createCanvas(600, 900);
strokeWeight(40);
for (i = 0; i < n; i++){
lines.push({
x1 : random(width),
x2 : random(3 * width / 8, 5 * width / 8),
vl : random(-10, 10),
cl : color(random(48, 96),
100,
100,
0.1
)
});
}
}
function draw() {
background(0);
for (i = 0; i < n; i++){
if (abs(lines[i].x1 - lines[i].x2) >= width * 1.5) {
lines[i].vl *= -1;
}
lines[i].x2 += lines[i].vl;
stroke(lines[i].cl);
line(lines[i].x1, 0, lines[i].x2, height);
}
}