roles
This commit is contained in:
parent
8c8cbfd7dd
commit
41d48bf60a
28 changed files with 434 additions and 7 deletions
21
utils/colors.go
Normal file
21
utils/colors.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package utils
|
||||
|
||||
import "math"
|
||||
|
||||
func IsDarkColor(r, g, b uint8) bool {
|
||||
rC := 0.299 * math.Pow(float64(r), 2)
|
||||
gC := 0.587 * math.Pow(float64(g), 2)
|
||||
bC := 0.114 * math.Pow(float64(b), 2)
|
||||
|
||||
lum := math.Sqrt(rC + gC + bC)
|
||||
|
||||
return lum <= 130
|
||||
}
|
||||
|
||||
func IntToRgb(color uint32) (uint8, uint8, uint8) {
|
||||
b := color % 256
|
||||
g := color / 256 % 256
|
||||
r := color / (256 * 256) % 256
|
||||
|
||||
return uint8(r), uint8(g), uint8(b)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue