Skip to content

Instantly share code, notes, and snippets.

@Noofbiz
Created July 29, 2016 19:12
Show Gist options
  • Save Noofbiz/8abca575cb6e631ae8d200001dffb960 to your computer and use it in GitHub Desktop.
Save Noofbiz/8abca575cb6e631ae8d200001dffb960 to your computer and use it in GitHub Desktop.
Intensity numbers to RGB
func intensityToRGB(i int) (r int, g int, b int){
region := i / 256
remainder := i % 256
switch region {
case 0:
r, b = 0, 255
g = remainder
case 1:
r, g = 0, 255
b = 255 - remainder
case 2:
g, b = 255, 0
r = remainder
case 3:
r, b = 255, 0
g = 255 - remainder
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment