xxxxxxxxxx
45
const w = 20;
let offset = 0;
class Stripe {
constructor(i, x, a) {
this.i = i;
this.x = x;
this.a = a + i/80;
this.speed = 0.02;
}
show() {
noStroke();
colorMode(HSB);
let h = map(sin(this.a+offset), -1, 1, 0, 360);
fill(255, 255, 255);
let ht = map(sin(this.a*2+offset),-1,1,10,height);
rect(this.x, height/2-ht/2, w-10, ht);
}
update() {
this.a += this.speed;
}
}
let stripes = [];
function setup() {
createCanvas(800, 400);
const cols = floor(width/w);
for (let i = 0; i < cols; i++) {
stripes[i] = new Stripe(i, i * w, 0);
}
}
function draw() {
//offset += 0.0;
background(0);
for (let s of stripes) {
s.show();
s.update();
}
}