Skip to content

Commit

Permalink
fix: fix intersection logic for rectangles
Browse files Browse the repository at this point in the history
  • Loading branch information
bertyhell committed Jul 28, 2024
1 parent fdfd8b8 commit 21c2cfa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/entities/RectangleEntity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Entity } from './Entitity.ts';
import { DrawInfo } from '../App.types.ts';
import { Box, Point, Shape } from '@flatten-js/core';
import { Box, Point, Relations, Shape } from '@flatten-js/core';

export class RectangleEntity implements Entity {
private rectangle: Box | null = null;
Expand Down Expand Up @@ -49,18 +49,18 @@ export class RectangleEntity implements Entity {
);
}

public intersectsWithBox(box: Box): boolean {
public intersectsWithBox(selectionBox: Box): boolean {
if (!this.rectangle) {
return false;
}
return this.rectangle.intersect(box);
return Relations.relate(this.rectangle, selectionBox).B2B.length > 0;
}

public isContainedInBox(box: Box): boolean {
public isContainedInBox(selectionBox: Box): boolean {
if (!this.rectangle) {
return false;
}
return box.contains(this.rectangle);
return selectionBox.contains(this.rectangle);
}

public getBoundingBox(): Box | null {
Expand Down

0 comments on commit 21c2cfa

Please sign in to comment.