xxxxxxxxxx
43
let levels = 0;
class Rectangle {
constructor(_x, _y, _w, _h, _r) {
this.x = _x;
this.y = _y;
this.w = _w;
this.h = _h;
this.r = _r;
this.splits = [];
}
show() {
push();
//translate(this.x,this.y);
fill(255, 127, 127);
rect(this.x, this.y, this.w, this.h);
fill(127, 255, 127);
//print(this.w - this.w / PLASTIC_RATIO);
rect(this.h / PLASTIC_RATIO / 2, this.y, this.h / PLASTIC_RATIO, this.h);
fill(127, 127, 255);
rect((this.w * 2) / 2.414213562, this.y, 100, 100);
pop();
// for (let s of this.splits) {
// s.show();
// if (levels++ < 4) s.split();
// }
}
split() {
this.splits.push(
new Rectangle(
this.w - this.w / PLASTIC_RATIO,
this.y,
this.w / PLASTIC_RATIO,
this.h,
this.r + 90
)
);
}
}