1
0
mirror of https://github.com/nikolaydubina/calendarheatmap.git synced 2025-03-04 16:15:45 +02:00

empty colorscale returns some value

This commit is contained in:
Nikolay 2021-02-27 16:00:39 +00:00 committed by GitHub
parent 513db54b64
commit 594a8f6c77

View File

@ -15,6 +15,9 @@ type BasicColorScale []color.RGBA
// GetColor returns color based on float value from 0 to 1
func (c BasicColorScale) GetColor(val float64) color.RGBA {
if len(c) == 0 {
return color.RGBA{}
}
maxIdx := len(c) - 1
idx := int(math.Round(float64(maxIdx) * val))
return c[idx]