xxxxxxxxxx
41
class Rect {
constructor(x, y, isBlack) {
this.x = x;
this.y = y;
this.isBlack = isBlack;
this.c = 0;
this.col = floor(random(7));
}
display() {
// Comment out for trail design
// if (this.isBlack == true) {
// this.c = 0;
// }
this.mouseHover();
fill(this.c);
strokeWeight(0.2);
rect(this.x, this.y, wsize, hsize);
}
mouseHover() {
let shapeColors = ["#abcd5e", "#14976b", "#2b67af", "#62b6de", "#f589a3", "#ef562f", "#fc8405", "#f9d531"];
let distance = dist(this.x, this.y, mouseX, mouseY);
if (distance < 50) {
if (this.isBlack == true) {
// this.c = 255;
// this.c = 0;
this.c = color(shapeColors[this.col]);
} else {
this.c = 0;
// this.c = 255;
}
}
if (this.c > 0) {
this.c -= 10;
}
}
}