支持为形状添加标记

This commit is contained in:
kercylan98
2023-05-31 14:00:33 +08:00
parent d2a6c5d8c7
commit e026d38b0c
3 changed files with 25 additions and 46 deletions

View File

@@ -1,28 +0,0 @@
package g2d
import (
"fmt"
"github.com/kercylan98/minotaur/utils/g2d/shape"
"testing"
)
func TestMatrixShape(t *testing.T) {
var m = [][]int{
{1, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
}
s := shape.NewShape()
s.AddPoints(shape.NewPointWithArrays([][2]int{{0, 0}, {0, 1}, {1, 1}, {2, 1}}...)...)
fmt.Println(s)
result := MatrixShapeSearchWithYX(m, []*shape.Shape{s}, func(val int) bool {
return val == 1
})
fmt.Println(len(result))
}