mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Master merge
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
parent
b4d8b04d9e
commit
336fa9d002
21 changed files with 189 additions and 157 deletions
|
@ -1,38 +1,38 @@
|
|||
import { point } from "./point";
|
||||
import { pointFrom } from "./point";
|
||||
import { rectangle, rectangleDistanceFromPoint } from "./rectangle";
|
||||
|
||||
describe("rectangle distance", () => {
|
||||
it("finds the shortest distance", () => {
|
||||
expect(
|
||||
rectangleDistanceFromPoint(
|
||||
rectangle(point(-1, -1), point(1, 1)),
|
||||
point(2, 0),
|
||||
rectangle(pointFrom(-1, -1), pointFrom(1, 1)),
|
||||
pointFrom(2, 0),
|
||||
),
|
||||
).toBe(1);
|
||||
expect(
|
||||
rectangleDistanceFromPoint(
|
||||
rectangle(point(-1, -1), point(1, 1)),
|
||||
point(0, 2),
|
||||
rectangle(pointFrom(-1, -1), pointFrom(1, 1)),
|
||||
pointFrom(0, 2),
|
||||
),
|
||||
).toBe(1);
|
||||
expect(
|
||||
rectangleDistanceFromPoint(
|
||||
rectangle(point(-1, -1), point(1, 1)),
|
||||
point(-2, 0),
|
||||
rectangle(pointFrom(-1, -1), pointFrom(1, 1)),
|
||||
pointFrom(-2, 0),
|
||||
),
|
||||
).toBe(1);
|
||||
expect(
|
||||
rectangleDistanceFromPoint(
|
||||
rectangle(point(-1, -1), point(1, 1)),
|
||||
point(0, -2),
|
||||
rectangle(pointFrom(-1, -1), pointFrom(1, 1)),
|
||||
pointFrom(0, -2),
|
||||
),
|
||||
).toBe(1);
|
||||
});
|
||||
it("finds the corner as closest point", () => {
|
||||
expect(
|
||||
rectangleDistanceFromPoint(
|
||||
rectangle(point(-1, -1), point(1, 1)),
|
||||
point(2, 2),
|
||||
rectangle(pointFrom(-1, -1), pointFrom(1, 1)),
|
||||
pointFrom(2, 2),
|
||||
),
|
||||
).toBe(Math.sqrt(2));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue