Created
March 11, 2013 12:56
-
-
Save gjedeer/5134047 to your computer and use it in GitHub Desktop.
C# 0.1024 -> colormap RGB implementation
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
int r; | |
int g; | |
int b; | |
if (point <= 128) // 1/8 | |
{ | |
r = 0; | |
g = 0; | |
b = 127 + point; // 0.5 ... 1 | |
} | |
else if (point <= 384) // 3/8 | |
{ | |
r = 0; | |
g = point - 129; // 0 .. 1 | |
b = 255; | |
} | |
else if (point <= 640.0) // 5/8 | |
{ | |
r = point - 385; | |
g = 255; | |
b = 640 - point; | |
} | |
else if (point <= 896) // 7/8 | |
{ | |
r = 255; | |
g = 896 - point; | |
b = 0; | |
} | |
else if (point <= 1024) | |
{ | |
r = (1024 + 128) - point; | |
g = 0; | |
b = 0; | |
} | |
else | |
{ | |
r = 255; | |
g = 255; | |
b = 255; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment