xxxxxxxxxx
80
let bars = [];
let yoff1 = 0.01;
let yoff2 = 0.01;
function setup() {
createCanvas(windowWidth, windowHeight);
let x = 0;
let y1 = height;
let y2 = 0;
let r = 0;
let g = 0;
let b = 0;
let a = 0;
for(i = 0; i < width / 4; i ++){
bars[i] = new Bar(x, y1, x, y2, r, g, b, a)
x = i * 4;
y2 = 0;
r = random(255);
g = random(255);
b = random(255);
a = random(1);
}
r = random(50);
g = random(50);
b = random(50);
background(r, g, b);
}
function draw() {
blendMode(ADD);
for(i = 0; i < bars.length; i ++){
bars[i].show();
bars[i].grow();
}
}
function mousePressed() {
noLoop();
}
class Bar {
constructor(x1, y1, x2, y2, r, g, b, a) {
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
grow() {
yoff1 = yoff1 + 0.01;
noiseSeed(1);
let n1 = noise(yoff1) * height;
this.y2 = n1;
yoff2 = yoff2 + 0.01;
noiseSeed(2);
let n2 = noise(yoff2) * height;
this.y1 = n2;
}
show() {
strokeWeight(random(300));
stroke(this.r, this.g, this.b, this.a);
line(this.x1, this.y1, this.x2, this.y2);
}
}