feat: support detect color dark or light

This commit is contained in:
vicanso 2022-11-16 20:46:19 +08:00
parent a42d0727df
commit 55eca7b0b9
6 changed files with 59 additions and 9 deletions

View file

@ -262,3 +262,10 @@ func getPolygonPoints(center Point, radius float64, sides int) []Point {
}
return points
}
func isLightColor(c Color) bool {
r := float64(c.R) * float64(c.R) * 0.299
g := float64(c.G) * float64(c.G) * 0.587
b := float64(c.B) * float64(c.B) * 0.114
return math.Sqrt(r+g+b) > 127.5
}