public WWColor[] getColorOverrides() { WWColor[] c = new WWColor[8]; for (int i = 0; i < 8; i++) { int t = SUN_ini.getIntValue("ColorOverrides", string.Format("Color{0}", i), -1); if (t > 0) { c[i] = WWColor.ByIndex(t); } } return(c); }
public static void HsvToRgb(WWColor self) { /* Similar to http://web.mit.edu/storborg/Public/hsvtorgb.c */ byte H = self.H; byte S = self.S; byte V = self.V; if (S == 0) { self.R = V; self.G = V; self.B = V; return; } byte R, G, B; byte region = (byte)(H / 43); byte fpart = (byte)((H - (region * 43)) * 6); byte p = (byte)((V * (255 - S)) >> 8); byte q = (byte)((V * (255 - ((S * fpart) >> 8))) >> 8); byte t = (byte)((V * (255 - ((S * (255 - fpart)) >> 8))) >> 8); switch (region) { // Red is the dominant color case 0: R = V; G = t; B = p; break; // Green is the dominant color case 1: R = q; G = V; B = p; break; case 2: R = p; G = V; B = t; break; // Blue is the dominant color case 3: R = p; G = q; B = V; break; case 4: R = t; G = p; B = V; break; // Red is the dominant color case 5: R = V; G = p; B = q; break; default: R = V; G = p; B = q; break; } self.R = R; self.G = G; self.B = B; }