public static Color Light(Color baseColor, float percOfLightLight) { if (baseColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb()) { int r_sub, g_sub, b_sub; Color color; if (percOfLightLight <= 0f) { return(ThemeEngine.Current.ColorControlLight); } if (percOfLightLight == 1.0f) { return(ThemeEngine.Current.ColorControlLightLight); } r_sub = ThemeEngine.Current.ColorControlLightLight.R - ThemeEngine.Current.ColorControlLight.R; g_sub = ThemeEngine.Current.ColorControlLightLight.G - ThemeEngine.Current.ColorControlLight.G; b_sub = ThemeEngine.Current.ColorControlLightLight.B - ThemeEngine.Current.ColorControlLight.B; color = Color.FromArgb(ThemeEngine.Current.ColorControlLight.A, (int)(ThemeEngine.Current.ColorControlLight.R + (r_sub * percOfLightLight)), (int)(ThemeEngine.Current.ColorControlLight.G + (g_sub * percOfLightLight)), (int)(ThemeEngine.Current.ColorControlLight.B + (b_sub * percOfLightLight))); return(color); } int H, I, S; ControlPaint.Color2HBS(baseColor, out H, out I, out S); int NewIntensity = Math.Min(255, I + (int)((255 - I) * 0.5f * percOfLightLight)); return(ControlPaint.HBS2Color(H, NewIntensity, S)); }
public static Color Dark(Color baseColor, float percOfDarkDark) { if (baseColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb()) { int r_sub, g_sub, b_sub; Color color; if (percOfDarkDark <= 0f) { return(ThemeEngine.Current.ColorControlDark); } if (percOfDarkDark == 1.0f) { return(ThemeEngine.Current.ColorControlDarkDark); } r_sub = ThemeEngine.Current.ColorControlDarkDark.R - ThemeEngine.Current.ColorControlDark.R; g_sub = ThemeEngine.Current.ColorControlDarkDark.G - ThemeEngine.Current.ColorControlDark.G; b_sub = ThemeEngine.Current.ColorControlDarkDark.B - ThemeEngine.Current.ColorControlDark.B; color = Color.FromArgb(ThemeEngine.Current.ColorControlDark.A, (int)(ThemeEngine.Current.ColorControlDark.R + (r_sub * percOfDarkDark)), (int)(ThemeEngine.Current.ColorControlDark.G + (g_sub * percOfDarkDark)), (int)(ThemeEngine.Current.ColorControlDark.B + (b_sub * percOfDarkDark))); return(color); } int H, I, S; ControlPaint.Color2HBS(baseColor, out H, out I, out S); int PreIntensity = Math.Max(0, I - (int)(I * 0.333f)); int NewIntensity = Math.Max(0, PreIntensity - (int)(PreIntensity * percOfDarkDark)); return(ControlPaint.HBS2Color(H, NewIntensity, S)); }