import Vec2 from './Vec2'; export default class Rect { constructor(pos = new Vec2(), size = new Vec2()) { this.pos = pos; this.size = size; } draw(ctx) { ctx.moveTo(this.left, this.top); ctx.lineTo(this.right, this.top); ctx.lineTo(this.right, this.bottom); ctx.lineTo(this.left, this.bottom); ctx.closePath(); ctx.stroke(); } get top() { return this.pos.y; } set top(n) { this.pos.y = n; } get bottom() { return this.pos.y + this.size.y; } set bottom(n) { this.pos.y = n - this.size.y; } get left() { return this.pos.x; } set left(n) { this.pos.x = n; } get right() { return this.pos.x + this.size.x; } set right(n) { this.pos.x = n - this.size.x; } }