diff --git a/go.mod b/go.mod index 214d58b..44c7629 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.23.0 toolchain go1.23.3 require ( + git.lxtend.com/lixiangwuxian/imagedd v0.0.0-20250510064143-ba9126d54ac6 github.com/bytedance/mockey v1.2.14 github.com/chromedp/cdproto v0.0.0-20241003230502-a4a8f7c660df github.com/chromedp/chromedp v0.10.0 @@ -28,7 +29,6 @@ require ( ) require ( - git.lxtend.com/lixiangwuxian/imagedd v0.0.0-20250510061940-c492839691e4 // indirect github.com/Microsoft/go-winio v0.4.14 // indirect github.com/andybalholm/brotli v1.1.1 // indirect github.com/bytedance/sonic v1.11.6 // indirect diff --git a/go.sum b/go.sum index bfa84ee..904ca58 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= git.lxtend.com/lixiangwuxian/imagedd v0.0.0-20250510061940-c492839691e4 h1:yDPaEFsQ7zj9NqLhl2iOY2bswn8+oNcGTl/1geJgeAs= git.lxtend.com/lixiangwuxian/imagedd v0.0.0-20250510061940-c492839691e4/go.mod h1:luas4p32Wtsywcz+8HsxIB3gf65FDDBa+3XYhm0S2b8= +git.lxtend.com/lixiangwuxian/imagedd v0.0.0-20250510064143-ba9126d54ac6 h1:v1cEHG5kGJN5Tu+3icJ6gfrcwrXJRZQMCu8eb4goEKQ= +git.lxtend.com/lixiangwuxian/imagedd v0.0.0-20250510064143-ba9126d54ac6/go.mod h1:luas4p32Wtsywcz+8HsxIB3gf65FDDBa+3XYhm0S2b8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= diff --git a/service/beatleader/model.go b/service/beatleader/model.go index c1cba5f..99aef2a 100644 --- a/service/beatleader/model.go +++ b/service/beatleader/model.go @@ -6,7 +6,6 @@ import ( "image/color" "image/draw" "log" - "math" "os" "strings" "time" @@ -619,15 +618,17 @@ func (p PlayerDataLite) LastDiffToImage(lastDayQueryData PlayerDataLite) string } baseboard.AddSprite(&textSpirit) - totalWidth := textImg.Bounds().Dx() + avatar.Bounds().Dx() - totalHeight := math.Max(float64(textImg.Bounds().Dy()), float64(avatar.Bounds().Dy())) + minX, minY, maxX, maxY := baseboard.GetRenderBounds() + totalWidth := maxX - minX + totalHeight := maxY - minY background := image.NewRGBA(image.Rect(0, 0, int(totalWidth), int(totalHeight))) draw.Draw(background, background.Bounds(), image.White, image.Point{}, draw.Src) backgroundSpirit := sprite.Sprite{ - Name: "background", - Image: background, - Index: 0, + Name: "background", + Image: background, + Index: 0, + Position: image.Point{X: minX, Y: minY}, } baseboard.AddSprite(&backgroundSpirit)