fix: set color min/max range

This commit is contained in:
Simon Vieille 2025-12-15 09:19:38 +01:00
commit 911fcc1ef5
Signed by: deblan
GPG key ID: 579388D585F70417

View file

@ -2,6 +2,7 @@ package color
import (
"image"
"math"
"github.com/lucasb-eyer/go-colorful"
)
@ -41,9 +42,13 @@ func GetRgbAverage(i *image.RGBA) RGB {
}
}
rangeValue := func(v float64) float64 {
return math.Min(250, math.Max(10, v))
}
return RGB{
R: float64(rSum) / float64(count),
G: float64(gSum) / float64(count),
B: float64(bSum) / float64(count),
R: rangeValue(float64(rSum) / float64(count)),
G: rangeValue(float64(gSum) / float64(count)),
B: rangeValue(float64(bSum) / float64(count)),
}
}