Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix out of range #6

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions serverpic.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,16 @@ func RenderServerPic(pluginlist []*PluginInfo, torussd, glowsd []byte, zbplogopa
cardimgs := make([]image.Image, 4)

wg := sync.WaitGroup{}
cardsnum := math.Ceil(ln, 4) * 3
cardsnum := ln / 4 * 3
wg.Add(4)
for i := 0; i < 3; i++ {
a := i * cardsnum
b := (i + 1) * cardsnum
go func(i int, list []*PluginInfo) {
defer wg.Done()
if b == 0 {
return
}
cardimgs[i], err = renderinfocards(torussd, glowsd, list)
if err != nil {
return
Expand All @@ -112,8 +115,10 @@ func RenderServerPic(pluginlist []*PluginInfo, torussd, glowsd []byte, zbplogopa
wg.Wait()
spacing := 0
for i := 0; i < len(cardimgs); i++ {
canvas.DrawImage(cardimgs[i], 0, serverlistlogo.Bounds().Dy()+spacing)
spacing += cardimgs[i].Bounds().Dy()
if cardimgs != nil {
canvas.DrawImage(cardimgs[i], 0, serverlistlogo.Bounds().Dy()+spacing)
spacing += cardimgs[i].Bounds().Dy()
}
}

img = canvas.Image()
Expand Down
Loading