Skip to content

Commit

Permalink
move node sorting to util func
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 30, 2024
1 parent 65d1bc3 commit 671c651
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 1 addition & 5 deletions isorenderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ func RenderIsometric(na types.NodeAccessor, cr types.ColorResolver, from, to *ty
}
}

slices.SortFunc(nodes, func(n1, n2 *NodeWithColor) int {
o1 := GetIsoNodeOrder(n1.Pos)
o2 := GetIsoNodeOrder(n2.Pos)
return o1 - o2
})
slices.SortFunc(nodes, SortNodesWithColor)

for _, n := range nodes {
rel_pos := n.Pos.Subtract(min)
Expand Down
6 changes: 6 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,9 @@ func BlendColor(bg, fg *color.RGBA, bf float64) *color.RGBA {
A: max(bg.A, fg.A),
}
}

func SortNodesWithColor(n1, n2 *NodeWithColor) int {
o1 := GetIsoNodeOrder(n1.Pos)
o2 := GetIsoNodeOrder(n2.Pos)
return o1 - o2
}

0 comments on commit 671c651

Please # to comment.