Skip to content

Commit

Permalink
fix out of range (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiang-Red authored Sep 11, 2024
1 parent 320312d commit 0728fc3
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit 0728fc3

Please sign in to comment.