From 52da4fcb5dc5bee0138ddd0c69d3f2258f788c9d Mon Sep 17 00:00:00 2001 From: Army Date: Fri, 3 Jan 2025 17:49:20 +0800 Subject: [PATCH] fix: --- src/math/geom.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/math/geom.ts b/src/math/geom.ts index 151a65a4..79ae2f5c 100644 --- a/src/math/geom.ts +++ b/src/math/geom.ts @@ -85,7 +85,13 @@ export function pointInConvexPolygon(x: number, y: number, vertexes: Array<{ x: // 判断点是否在一个矩形,比如事件发生是否在节点上 export function pointInRect(x: number, y: number, x1: number, y1: number, x2: number, y2: number, - matrix: Float64Array, includeIntersect: boolean = false) { + matrix?: Float64Array, includeIntersect: boolean = false) { + if (x1 >= x2) { + [x1, x2] = [x2, x1]; + } + if (y1 >= y2) { + [y1, y2] = [y2, y1]; + } if (matrix && !isE(matrix)) { const t1 = calPoint({ x: x1, y: y1 }, matrix); const t2 = calPoint({ x: x2, y: y1 }, matrix);