xxxxxxxxxx
33
class Rect {
constructor(x, y, b) {
this.x = x;
this.y = y;
this.b = b;
this.col = floor(random(7));
this.c = 255;
// if (this.b == 0) {
// this.c = 0;
// } else {
// this.c = 255;
// }
}
display() {
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 < 20) {
if (this.b == 0) {
this.c = color(shapeColors[this.col]);
}
}
}
}