fix gradient color selection out of range for dynamic resize case

This commit is contained in:
sqshq 2019-04-10 23:58:42 -04:00
parent 25f5a99de9
commit db9e76bec3
1 changed files with 3 additions and 0 deletions

View File

@ -67,6 +67,9 @@ func GetPalette(theme Theme) Palette {
}
func GetGradientColor(gradient []ui.Color, cur int, max int) ui.Color {
if cur > max {
cur = max
}
ratio := float64(len(gradient)) / float64(max)
return gradient[int(ratio*float64(cur))]
}