Created
December 14, 2015 15:00
-
-
Save leegee/d142fd6af0d51598c110 to your computer and use it in GitHub Desktop.
Hue from RGB
This file contains 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
// https://en.wikipedia.org/wiki/Hue#Computing_hue_from_RGB | |
else if ((r >= g) && (g >= b)) { | |
rvXy[x][y] = 60 * ( (g-b) / (r-b) ); | |
} | |
else if ((g > r) && (r >= b)) { | |
rvXy[x][y] = 60 * (2 - ( (r-b) / (g-b) )); | |
} | |
else if ((g >= b) && (g > r)) { | |
rvXy[x][y] = 60 * (2 + ( (b-r) / (g-r) )); | |
} | |
else if ((b > g) && (b > r)) { | |
rvXy[x][y] = 60 * (4 - ( (g-r) / (b-r) )); | |
} | |
else if ((b > r) && (b >= g)) { | |
rvXy[x][y] = 60 * (4 + ( (r-g) / (b-g) )); | |
} | |
else { // if ((r >= b) && (r > g)) { | |
rvXy[x][y] = 60*(6 - (b-g)/(r-g)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment