Exemplo n.º 1
0
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var color      = (CommonColor)value;
            var hue        = color.Hue;
            var lightness  = color.Lightness;
            var colorStart = CommonColor.FromHLS(hue, lightness, 0).ToColor();
            var colorEnd   = CommonColor.FromHLS(hue, lightness, 1).ToColor();

            return(ConvertImplementation(colorStart, colorEnd));
        }
 public static CommonColor UpdateHLS(
     this CommonColor color,
     double?hue        = null,
     double?lightness  = null,
     double?saturation = null,
     byte?alpha        = null)
 {
     return(CommonColor.FromHLS(
                hue: hue ?? color.Hue,
                lightness: lightness ?? color.Lightness,
                saturation: saturation ?? color.Saturation,
                alpha: alpha ?? color.A));
 }
Exemplo n.º 3
0
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var color      = (CommonColor)value;
            var hue        = color.Hue;
            var saturation = color.Saturation;
            var colorStart = CommonColor.FromHLS(hue, 0, saturation).ToColor();
            var colorEnd   = CommonColor.FromHLS(hue, 1, saturation).ToColor();

            return(new LinearGradientBrush(new GradientStopCollection {
                new GradientStop(colorStart, 0),
                new GradientStop(color.ToColor(), color.Lightness),
                new GradientStop(colorEnd, 1)
            }, 0));
        }
        public HLS HLSRoundTripTest(HLS hls)
        {
            var color = CommonColor.FromHLS(hls.Hue, hls.Lightness, hls.Saturation);

            return(new HLS(color.Hue, color.Lightness, color.Saturation));
        }
 public CommonColor ColorFromHLSTest(HLS hls) => CommonColor.FromHLS(hls.Hue, hls.Lightness, hls.Saturation);