xxxxxxxxxx
36
class Rect {
constructor(x, y, h) {
this.pos = createVector(x, y);
this.h = h; // determine by perlin noise
this.vh = 0.1; // change in this.h
this.ah = 0.01; // change in this.vh
this.size = size;
}
move() {
this.vh += this.ah;
if (this.vh >= 1) {
this.ah *= -1;
}
// this.vh = constrain(this.vh, 0, 1);
this.h += this.vh;
// if (this.h > this.size || this.h < 0) {
// this.vh *= -1;
// }
// print(this.ah, this.vh, this.h);
}
display() {
push();
translate(this.pos.x, this.pos.y);
noStroke();
fill(255);
rect(0, 0, this.size, this.size);
fill(0);
rect(0, 0, this.size, this.h);
pop();
}
}