public Colour(HSLColour Clr) { ushort H = Clr.H; double S = Clr.S; double L = Clr.L; double C = (1 - Math.Abs(2 * L - 1)) * S; double X = C * (1 - Math.Abs(((double)H / (double)60) % 2 - 1)); double m = L - C / 2; double r = 0; double g = 0; double b = 0; switch (H / 60) { case 0: { r = C; g = X; b = 0; break; } case 1: { r = X; g = C; b = 0; break; } case 2: { r = 0; g = C; b = X; break; } case 3: { r = 0; g = X; b = C; break; } case 4: { r = X; g = 0; b = C; break; } case 5: { r = C; g = 0; b = X; break; } } R = (byte)((r + m) * 255); G = (byte)((g + m) * 255); B = (byte)((b + m) * 255); A = Clr.A; }
private void trackBar1_ValueChanged(object sender, EventArgs e) { foreach (Palette P in AP.Palettes) { for (int i = 0; i < P.Colours.Count; i++) { HSLColour Temp = new HSLColour(P.Colours[i]); if (Temp.S > 0.5) // Saturate parts, such as armour { Temp.H = (ushort)trackBar1.Value; P.Colours[i] = new Colour(Temp); } } } }
public Colour(HSLColour Clr) { ushort H = Clr.H; double S = Clr.S; double L = Clr.L; double C = (1 - Math.Abs(2 * L - 1)) * S; double X = C * (1 - Math.Abs(((double)H / (double)60) % 2 - 1)); double m = L - C / 2; double r = 0; double g = 0; double b = 0; switch (H / 60) { case 0: { r = C; g = X; b = 0; break; } case 1: { r = X; g = C; b = 0; break; } case 2: { r = 0; g = C; b = X; break; } case 3: { r = 0; g = X; b = C; break; } case 4: { r = X; g = 0; b = C; break; } case 5: { r = C; g = 0; b = X; break; } } R = (byte)((r + m) * 255); G = (byte)((g + m) * 255); B = (byte)((b + m) * 255); A = Clr.A; }