diagram: select more nodes by drag rectangke

This commit is contained in:
Jan Prochazka
2022-01-20 12:52:20 +01:00
parent a530a353b6
commit c0891af5c3
4 changed files with 96 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import { arrayDifference } from 'interval-operations';
import { intersection, arrayDifference } from 'interval-operations';
import _ from 'lodash';
export interface IPoint {
x: number;
y: number;
@@ -101,6 +102,13 @@ export function rectangleIntersectArea(rect1: IBoxBounds, rect2: IBoxBounds) {
return x_overlap * y_overlap;
}
export function rectanglesHaveIntersection(rect1: IBoxBounds, rect2: IBoxBounds) {
const xIntersection = intersection([rect1.left, rect1.right], [rect2.left, rect2.right]);
const yIntersection = intersection([rect1.top, rect1.bottom], [rect2.top, rect2.bottom]);
return !!xIntersection && !!yIntersection;
}
export class Vector2D {
constructor(public x: number, public y: number) {}