From 540d671d8cee9b2053710208597ede5f83054ba4 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Mon, 5 Jun 2023 19:39:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=AA=E7=BA=BF=E7=9B=B4=E7=BA=BF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2bug=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/g2d/shape.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/utils/g2d/shape.go b/utils/g2d/shape.go index 8b7f013..75576c9 100644 --- a/utils/g2d/shape.go +++ b/utils/g2d/shape.go @@ -250,9 +250,6 @@ func SearchNotRepeatStraightLine(minLength int, xys ...[2]int) (result [][][2]in find[1] = true points = append(points, [2]int{sx + left, y + top}) } - if !find[1] { - goto up - } for sx := x + 1; sx < len(rectangleShape); sx++ { if !rectangleShape[sx][y] { break @@ -260,10 +257,11 @@ func SearchNotRepeatStraightLine(minLength int, xys ...[2]int) (result [][][2]in find[2] = true points = append(points, [2]int{sx + left, y + top}) } - if !find[2] { + if len(find) == 2 { + goto end + } else { points = nil } - up: for sy := y - 1; sy >= 0; sy-- { if !rectangleShape[x][sy] { break @@ -271,9 +269,6 @@ func SearchNotRepeatStraightLine(minLength int, xys ...[2]int) (result [][][2]in find[3] = true points = append(points, [2]int{x + left, sy + top}) } - if !find[3] { - continue - } for sy := y + 1; sy < len(rectangleShape[0]); sy++ { if !rectangleShape[x][sy] { break @@ -281,13 +276,16 @@ func SearchNotRepeatStraightLine(minLength int, xys ...[2]int) (result [][][2]in find[4] = true points = append(points, [2]int{x + left, sy + top}) } - if !find[4] { + if !find[3] && !find[4] { continue } - if len(find) != 2 { - continue + end: + { + if len(find) != 2 { + continue + } + result = append(result, append(points, [2]int{x + left, y + top})) } - result = append(result, append(points, [2]int{x + left, y + top})) } sort.Slice(result, func(i, j int) bool {