SHARE
TWEET

Rotate Hue

ForeverZer0 Feb 19th, 2012 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Color RotateHue(float hue)
  2. {
  3.         float f, q;
  4.         int i;
  5.  
  6.         if (hue >= 360f || hue <= 0)
  7.                 hue = 0;
  8.  
  9.         hue /= 60f;
  10.         i = (int) Math.Floor(hue);
  11.         f = hue - (float) i;
  12.         q = 1 - f;
  13.  
  14.         int r, g, b;
  15.  
  16.         switch (i)
  17.         {
  18.                 case 0:
  19.                         r = 255; g = (int)(255*f)%256; b = 0;
  20.                         break;
  21.                 case 1:
  22.                         r = (int)(255*q)%256; g = 255; b = 0;
  23.                         break;
  24.                 case 2:
  25.                         r = 0; g = 255; b = (int)(255*f)%256;
  26.                         break;
  27.                 case 3:
  28.                         r = 0; g = (int)(255*q)%256; b = 255;
  29.                         break;
  30.                 case 4:
  31.                         r = (int)(255*f)%256; g = 0; b = 255;
  32.                         break;
  33.                 default:
  34.                         r = 255; g = 0; b = (int)(255*q)%256;
  35.                         break;
  36.         }
  37.  
  38.         return Color.FromArgb(r, g, b);
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top