コード例 #1
0
        public static void Firefly(Bulb bulb)
        {
            bulb.SetColorLevel(0, 0, 0);
            Colors firelyColor = new Colors(140, 255, 0, 0, 0);
            int    DelayBetweenPulses = RandomNumber(5000, 10000), openDelaySpeed = RandomNumber(20, 50), closeDelaySpeed = RandomNumber(5, 10);



            Thread.Sleep(DelayBetweenPulses);

            Flash(bulb, firelyColor, openDelaySpeed, 0, 1.0);
            Flash(bulb, firelyColor, closeDelaySpeed, 1.0, 0);
            Thread.Sleep(100);
            bulb.SetColorLevel(0, 0, 0);
        }
コード例 #2
0
        public static void FlyingLantern(Bulb bulb, double luminocity, double resolution)
        {
            bulb.SetColorLevel(0, 0, 0);
            int openDelaySpeed     = RandomNumber(100, 200),
                delayBetweenPulses = RandomNumber(1, 60000),
                twinkles           = RandomNumber(5, 20);

            Console.WriteLine(delayBetweenPulses);

            Thread.Sleep(delayBetweenPulses);

            Colors randomBlue = new Colors(RandomNumber((byte)0, (byte)20), RandomNumber((byte)0, (byte)255), RandomNumber((byte)50, (byte)255), 0, 0);
            Colors randomPink = new Colors(255, 0, RandomNumber((byte)5, (byte)220), 0, 0);
            Colors transitionColor;



            int randomChance = RandomNumber((int)0, (int)2);

            if (randomChance == 1)
            {
                transitionColor = randomPink;
            }
            else
            {
                transitionColor = randomBlue;
            }

            ColorTransition(bulb, bulb.Colors, transitionColor, openDelaySpeed, resolution, luminocity);

            for (int i = 0; i < twinkles; i++)
            {
                int    twinkleSpeed   = RandomNumber(10, 25);
                double dimLuminocity  = RandomNumber(.40, .65);
                int    brightDuration = RandomNumber(1000, 5000);


                Flash(bulb, transitionColor, twinkleSpeed, luminocity, luminocity * dimLuminocity);
                Flash(bulb, transitionColor, twinkleSpeed, luminocity * dimLuminocity, luminocity);
                Thread.Sleep(brightDuration);
            }
        }