💥 移除g2d包,合并到geometry包
This commit is contained in:
parent
4f05f7f522
commit
261b14e789
|
@ -4,7 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
jsonIter "github.com/json-iterator/go"
|
jsonIter "github.com/json-iterator/go"
|
||||||
"github.com/kercylan98/minotaur/utils/g2d/matrix"
|
"github.com/kercylan98/minotaur/utils/geometry/matrix"
|
||||||
"github.com/kercylan98/minotaur/utils/str"
|
"github.com/kercylan98/minotaur/utils/str"
|
||||||
"github.com/kercylan98/minotaur/utils/xlsxtool"
|
"github.com/kercylan98/minotaur/utils/xlsxtool"
|
||||||
"github.com/tealeg/xlsx"
|
"github.com/tealeg/xlsx"
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
package g2d
|
|
||||||
|
|
||||||
// SlideDrop 侧滑掉落特定位置成员
|
|
||||||
func SlideDrop[T any](matrix [][]T, x, y int, isStop func(start T, x, y int, data T) bool) (dropX, dropY int) {
|
|
||||||
width, height := len(matrix), len(matrix[0])
|
|
||||||
start := matrix[x][y]
|
|
||||||
var offsetX, offsetY = -1, 1
|
|
||||||
for {
|
|
||||||
targetX, targetY := x+offsetX, y+offsetY
|
|
||||||
if targetX < 0 || targetY == height || isStop(start, targetX, targetY, matrix[targetX][targetY]) {
|
|
||||||
dropX, dropY = targetX+1, targetY-1
|
|
||||||
break
|
|
||||||
}
|
|
||||||
offsetX--
|
|
||||||
offsetY++
|
|
||||||
}
|
|
||||||
offsetX, offsetY = 1, 1
|
|
||||||
for dropX != x && dropY != y {
|
|
||||||
targetX, targetY := x+offsetX, y+offsetY
|
|
||||||
if targetX == width || targetY == height || isStop(start, targetX, targetY, matrix[targetX][targetY]) {
|
|
||||||
dropX, dropY = targetX-1, targetY-1
|
|
||||||
break
|
|
||||||
}
|
|
||||||
offsetX++
|
|
||||||
offsetY++
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// VerticalDrop 垂直掉落特定位置成员
|
|
||||||
func VerticalDrop[T any](matrix [][]T, x, y int, isStop func(start T, x, y int, data T) bool) (dropX, dropY int) {
|
|
||||||
height := len(matrix[0])
|
|
||||||
start := matrix[x][y]
|
|
||||||
var offsetY = 1
|
|
||||||
for {
|
|
||||||
testY := y + offsetY
|
|
||||||
if testY == height || isStop(start, x, testY, matrix[x][testY]) {
|
|
||||||
return x, testY - 1
|
|
||||||
}
|
|
||||||
offsetY++
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
package xlsxtool
|
package xlsxtool
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/kercylan98/minotaur/utils/g2d/matrix"
|
"github.com/kercylan98/minotaur/utils/geometry/matrix"
|
||||||
"github.com/tealeg/xlsx"
|
"github.com/tealeg/xlsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue