UNPKG

@visactor/vtable

Version:

canvas table width high performance

63 lines (61 loc) 1.5 kB
import { Bounds } from "@visactor/vutils"; export class Rect { constructor(left, top, width, height) { this.bounds = new Bounds, this.bounds.set(left, top, left + width, top + height); } static bounds(left, top, right, bottom) { return new Rect(left, top, Math.round(right - left), Math.round(bottom - top)); } get left() { return this.bounds.x1; } set left(left) { this.bounds.x1 = left; } get top() { return this.bounds.y1; } set top(top) { this.bounds.y1 = top; } get right() { return this.bounds.x2; } set right(right) { this.bounds.x2 = right; } get bottom() { return this.bounds.y2; } set bottom(bottom) { this.bounds.y2 = bottom; } get width() { return this.bounds.width(); } set width(width) { this.bounds.x2 = this.bounds.x1 + width; } get height() { return this.bounds.height(); } set height(height) { this.bounds.y2 = this.bounds.y1 + height; } offsetLeft(offset) { this.bounds.translate(offset, 0); } offsetTop(offset) { this.bounds.translate(0, offset); } copy() { return new Rect(this.left, this.top, this.width, this.height); } contains(another) { return this.bounds.encloses(another.bounds); } inPoint(x, y) { return this.bounds.contains(x, y); } } //# sourceMappingURL=Rect.js.map