Пример #1
0
        public static Color AddLuminosity(this Color color, float delta)
        {
            ColorConverters.ConvertToHsl(color.R / 255f, color.G / 255f, color.B / 255f, out var h, out var s, out var l);
            var newL = l + delta;

            ColorConverters.ConvertToRgb(h, s, newL, out var r, out var g, out var b);
            return(Color.FromArgb(color.A, r, g, b));
        }
Пример #2
0
 public static Color WithLuminosity(this Color color, float luminosity)
 {
     ColorConverters.ConvertToHsl(color.R / 255f, color.G / 255f, color.B / 255f, out var h, out var s, out var l);
     ColorConverters.ConvertToRgb(h, s, luminosity / 100f, out var r, out var g, out var b);
     return(Color.FromArgb(color.A, r, g, b));
 }
Пример #3
0
 public static Color WithSaturation(this Color color, float saturation)
 {
     ColorConverters.ConvertToHsl(color.R / 255f, color.G / 255f, color.B / 255f, out var h, out var s, out var l);
     ColorConverters.ConvertToRgb(h, saturation / 100f, l, out var r, out var g, out var b);
     return(Color.FromArgb(color.A, r, g, b));
 }
Пример #4
0
 public static Color WithHue(this Color color, float hue)
 {
     ColorConverters.ConvertToHsl(color.R / 255f, color.G / 255f, color.B / 255f, out var h, out var s, out var l);
     ColorConverters.ConvertToRgb(hue / 360f, s, l, out var r, out var g, out var b);
     return(Color.FromArgb(color.A, r, g, b));
 }