export const useSelectionRect = defineStore('selection-rect', { state: () => ({ enabled: false as boolean, a: { x: 0 as number, y: 0 as number, }, b: { x: 0 as number, y: 0 as number, }, }), actions: { set(a: { x: number; y: number }, b: { x: number; y: number }) { this.a.x = a.x; this.a.y = a.y; this.b.x = b.x; this.b.y = b.y; this.enabled = true; }, updateB(x: number, y: number) { this.b.x = x; this.b.y = y; }, disable() { this.enabled = false; }, isMinSize(minPixels: number = 10) { return ( Math.max( Math.abs(this.a.x - this.b.x), Math.abs(this.a.y - this.b.y) ) >= minPixels ); }, }, });