Skip to content

Commit

Permalink
Fix index out of range in LayoutHighlights
Browse files Browse the repository at this point in the history
  • Loading branch information
SmilyOrg committed May 12, 2024
1 parent 297f29b commit 0017568
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/layout/highlights.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ func LayoutHighlights(infos <-chan image.InfoEmb, layout Layout, scene *render.S

// fmt.Printf("queue %d\n", node.Index)

prevHeight := photos[0].Height
prevHeight := float32(0.)
if nodeIndex+1 < len(photos) {
prevHeight = photos[nodeIndex+1].Height
}

for i := nodeIndex + 1; i < len(photos); i++ {
photo := photos[i]
Expand All @@ -185,7 +188,7 @@ func LayoutHighlights(infos <-chan image.InfoEmb, layout Layout, scene *render.S
valid := photoHeight >= minHeight && photoHeight <= maxHeight || i == len(photos)-1 || fallback
// badness := math.Abs(photoHeight - idealHeight)
badness := math.Abs(photoHeight - float64(photo.Height))
prevDiff := 0.1 * math.Abs(float64(prevHeight-photo.Height))
prevDiff := 10 * math.Abs(float64(prevHeight-photo.Height))
prevHeight = photo.Height
// viewportDiff := 1000. * float64(photoHeight)
viewportDiff := 1000. * math.Max(0, float64(photoHeight)-layout.ViewportHeight)
Expand Down

0 comments on commit 0017568

Please sign in to comment.