Skip to content

Instantly share code, notes, and snippets.

@esdrasbeleza
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esdrasbeleza/b650b6f4b04fe44ef445 to your computer and use it in GitHub Desktop.
Save esdrasbeleza/b650b6f4b04fe44ef445 to your computer and use it in GitHub Desktop.
lightest() function
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