Ejemplo n.º 1
0
 protected override void OnColorChanged()
 {
     double lightness = HslColor.Lightness;
     base.OnColorChanged();
     PointLightness = HslColor.Lightness;
     PointBrush.Color = PointColor.MediaColor();
     if (HslColor.Lightness < 0.2)
         lightness = 0.2;
     HslColor hsl = new HslColor(HslColor.Hue, HslColor.Saturation, lightness);
     PureBrush.Color = hsl.ToRGB().MediaColor();
 }
Ejemplo n.º 2
0
        private void MakeGradient(PatternPoint from, PatternPoint to)
        {
            HslColor hsl;
            int stepCount = 0;
            PatternPoint tmpFrom = null;

            if (to.Variant == PointVariant.Range)
                for (int i = 0; i < to.LedCount; i++)
                    StripModel[to.LedPos + i - 1].PointColor = to.PointColor;

            if (from.Variant == PointVariant.Range)
            {
                for (int i = 0; i < from.LedCount; i++)
                    StripModel[from.LedPos + i - 1].PointColor = from.PointColor;
                tmpFrom = new PatternPoint(from.PointColor, from.LedPos + from.LedCount - 1);
            }
            else
                tmpFrom = from;

            stepCount = to.LedPos - tmpFrom.LedPos;
            double deltaHue = (to.HslColor.Hue - tmpFrom.HslColor.Hue) / stepCount;
            double deltaSat = (to.HslColor.Saturation - tmpFrom.HslColor.Saturation) / stepCount;
            double deltaBri = (to.HslColor.Lightness - tmpFrom.HslColor.Lightness) / stepCount;

            StripModel[tmpFrom.LedPos - 1].PointColor = tmpFrom.PointColor;
            //Console.WriteLine("Pos: {0}  Hue: {1},  Lightness: {2}", from.LedPos, from.HslColor.Hue, from.HslColor.Lightness);
            StripModel[to.LedPos - 1].PointColor = to.PointColor;

            for (int i = 1; i < stepCount; i++)
            {
                hsl = new HslColor(from.HslColor.Hue + i * deltaHue,
                                   from.HslColor.Saturation + i * deltaSat,
                                   from.HslColor.Lightness + i * deltaBri);
                StripModel[tmpFrom.LedPos + i - 1].PointColor = hsl.ToRGB();
                //Console.WriteLine("Pos: {0}  Hue: {1},  Lightness: {2}", from.LedPos + i, hsl.Hue, hsl.Lightness);
            }
            //Console.WriteLine("Pos: {0}  Hue: {1},  Lightness: {2}", to.LedPos, to.HslColor.Hue, to.HslColor.Lightness);
        }