Skip to content

Instantly share code, notes, and snippets.

Created January 31, 2013 16:03
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 anonymous/4683934 to your computer and use it in GitHub Desktop.
Save anonymous/4683934 to your computer and use it in GitHub Desktop.
stdin
float r, g, b;
if (a < .13) r = 0;
else if (a < .73) r = 1 * sin((a - .13) / .60 * M_PI / 2);
else r = 1;
if (a < .60) g = 0;
else if (a < .91) g = 1 * sin((a - .60) / .31 * M_PI / 2);
else g = 1;
if (a < .60) b = .5 * sin((a - .00) / .60 * M_PI);
else if (a < .78) b = 0;
else b = (a - .78) / .22;
y = 0.114 * b + 0.587 * g + 0.299 * r;
u = 0.5 * b - 0.331 * g - 0.169 * r;
v = -0.081 * b - 0.419 * g + 0.5 * r;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment