public static Color Lighter(Color c1, double value = 0.2)
 {
     var rgb = new Spectrum.Color.RGB(c1.R, c1.G, c1.B);
     var hsl = rgb.ToHSL();
     hsl = hsl.ShiftLightness(value);
     rgb = hsl.ToRGB();
     return Color.FromArgb(255, rgb.R, rgb.G, rgb.B);
 }
Example #2
0
        private static void FadeAll(int by)
        {
            double fade = (255.0 - by) / 255.0;

            for (int i = 0; i < 50; i++)
            {
                Leds[i] = new Spectrum.Color.RGB(Convert.ToByte(Leds[i].R * fade), Convert.ToByte(Leds[i].G * fade), Convert.ToByte(Leds[i].B * fade));
            }
        }
Example #3
0
        private void BackgroundWorker_DoWork(object tokenObject)
        {
            var cancellationToken = (CancellationToken)tokenObject;

            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    var Origin = new Spectrum.Color.RGB(Effects.Colors[0].R, Effects.Colors[0].G, Effects.Colors[0].B).ToHSL();

                    var Destiny = new Spectrum.Color.RGB(Effects.Colors[1].R, Effects.Colors[1].G, Effects.Colors[1].B).ToHSL();

                    List <LEDBulb> comet = new List <LEDBulb>();

                    for (int i = 0; i < App.settings.Length; i++)
                    {
                        comet.Add(new LEDBulb());
                    }

                    var step = (Origin.H - Destiny.H) / comet.Count;

                    if (step > 0)
                    {
                        for (int i = 1; i <= comet.Count; i++)
                        {
                            comet[i - 1] = new Spectrum.Color.HSL(step * i, Origin.S, Origin.L);
                        }
                    }


                    //comet[0] = Effects.Colors[0];
                    //comet[comet.Count - 1] = Effects.Colors[1];

                    //for (int i = 1; i < comet.Count - 1; i++)
                    //{
                    //    Console.WriteLine(i);
                    //    if (RStep > 1 || RStep < -1)
                    //    {
                    //        comet[i].R = Byte.Parse(Math.Floor(comet[i - 1].R - RStep).ToString());
                    //    }
                    //    if (GStep > 1 || GStep < -1)
                    //    {
                    //        comet[i].G = Byte.Parse(Math.Floor(comet[i - 1].G - GStep).ToString());
                    //    }
                    //    if (BStep > 1 || BStep < -1)
                    //    {
                    //        comet[i].B = Byte.Parse(Math.Floor(comet[i - 1].B - BStep).ToString());
                    //    }
                    //}

                    //for (int i = 0; i < App.settings.Length; i++)
                    //{
                    //    comet.Add(new LEDBulb());

                    //    if (RStep > 1)
                    //    {
                    //        comet[i].R = Byte.Parse((Effects.Colors[0].R - (RStep * i)).ToString());
                    //    }
                    //    else if (RStep < 0)
                    //    {
                    //        comet[i].R = Byte.Parse(((RStep * i) + Effects.Colors[1].R).ToString());
                    //    }
                    //    else
                    //    {
                    //        comet[i].R = 0;
                    //    }

                    //    if (GStep > 1)
                    //    {
                    //        comet[i].G = Byte.Parse((Effects.Colors[0].G - (GStep * i)).ToString());
                    //    }
                    //    else if (GStep < 0)
                    //    {
                    //        comet[i].G = Byte.Parse(((GStep * i) + Effects.Colors[1].G).ToString());
                    //    }
                    //    else
                    //    {
                    //        comet[i].G = 0;
                    //    }
                    //    if (BStep > 1)
                    //    {
                    //        comet[i].B = Byte.Parse((Effects.Colors[0].B - (BStep * i)).ToString());
                    //    }
                    //    else if (BStep < 0)
                    //    {
                    //        comet[i].B = Byte.Parse(((BStep * i) + Effects.Colors[1].B).ToString());
                    //    }
                    //    else
                    //    {
                    //        comet[i].B = 0;
                    //    }
                    //}

                    Effects.CometMode(comet);
                    Thread.Sleep(App.settings.Speed);
                }
                catch (OperationCanceledException)
                {
                    return;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }