Skip to content

Instantly share code, notes, and snippets.

@gjedeer
Created March 11, 2013 12:56
Show Gist options
  • Save gjedeer/5134047 to your computer and use it in GitHub Desktop.
Save gjedeer/5134047 to your computer and use it in GitHub Desktop.
C# 0.1024 -> colormap RGB implementation
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