From 53722ddeae409a4d3af66b0dbdd79235f1844651 Mon Sep 17 00:00:00 2001 From: LeeWannacott Date: Sat, 14 Oct 2023 15:45:54 +1300 Subject: [PATCH] Fix bug if horizontal frames less than hframes for go routines. --- src/gontage.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gontage.go b/src/gontage.go index 653604d..35a610c 100644 --- a/src/gontage.go +++ b/src/gontage.go @@ -158,7 +158,13 @@ func calcSheetDimensions(hframes int, all_decoded_images []image.Image) (int, in vframes := math.Ceil((float64(len(all_decoded_images)) / float64(hframes))) var spritesheet_width int var spritesheet_height int - for _, image := range all_decoded_images[:hframes] { + var horizontal_sprite_count int + if len(all_decoded_images) < hframes { + horizontal_sprite_count = len(all_decoded_images) + } else { + horizontal_sprite_count = hframes + } + for _, image := range all_decoded_images[:horizontal_sprite_count] { spritesheet_width += image.Bounds().Dx() } for _, image := range all_decoded_images[:int(vframes)] {