fix: set color min/max range
This commit is contained in:
parent
0ec63b9792
commit
911fcc1ef5
1 changed files with 8 additions and 3 deletions
|
|
@ -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)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue