feat: support detect color dark or light
This commit is contained in:
parent
a42d0727df
commit
55eca7b0b9
6 changed files with 59 additions and 9 deletions
7
util.go
7
util.go
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue