Esempio n. 1
0
            /// <summary>
            /// Creates a rainbow effect by iterating through hue values.
            /// How fast the effect goes depends on the speed param, and the hueStep param.
            ///     The higher the speed value, the lower the hueStep should be.
            ///     At high delay times, lighting updates can be seen. This can be offset
            ///         by reducing how much the hue value is incremented each loop.
            ///
            /// Speed Values:
            ///     Fastest Reccomended - Speed: 5 at hueStep: 0.01
            ///     Good Middle Speed   - Speed: 50 at hueStep: 0.01
            ///     Slowest Reccomended - Speed: 100 at hueStep: 0.001
            /// </summary>
            /// <param name="speed"></param>
            public static void FadingEffect(int speed = 50, double hueStep = 0.01)
            {
                Clog(String.Format("Setting Rainbow Fade Effect -- Speed: {0} - Hue Step: {1}", speed, hueStep));
                ILedGroup ledGroup = new ListLedGroup(surface.Leds);

                while (true)
                {
                    for (double j = 0; j < 1; j += hueStep)
                    {
                        RGBColor c = ColorMethods.HSLToRGB(j, 1.0, 0.5);
                        ledGroup.Brush = new SolidColorBrush(new Color(c.R, c.G, c.B));
                        Thread.Sleep(speed);
                    }
                }
            }
Esempio n. 2
0
 public static int[] RGBToArr(RGBColor color) => new int[]
 {
     color.R, color.G, color.B
 };
Esempio n. 3
0
 /// <summary>
 /// Converts an RGBColor object to a hex string
 /// </summary>
 /// <param name="color">The RGB object to convert</param>
 /// <returns>A hex string</returns>
 public static string RGBToHex(RGBColor color) => color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");