Last active
August 29, 2015 14:20
-
-
Save esdrasbeleza/b650b6f4b04fe44ef445 to your computer and use it in GitHub Desktop.
lightest() function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c LightestOperation) lightest(color1, color2 color.RGBA) color.Color { | |
if c.luminance(color1) > c.luminance(color2) { | |
return color1 | |
} else { | |
return color2 | |
} | |
} | |
func (c LightestOperation) luminance(someColor color.Color) uint32 { | |
r, g, b, _ := someColor.RGBA() | |
return uint32(0.2126*float32(r) + 0.7152*float32(g) + 0.0722*float32(b)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment