/// <summary>
 /// Add an animation.
 /// </summary>
 /// <param name="animation">The animation.</param>
 public void AddAnimation(Animation animation)
 {
     animation.Current = -animation.DelayCount;
     _animations.Add(animation);
 }
        Animation GetRandomColorItem(int pixelIndex, int startCount, int endCount)
        {
            Animation item =
                new Animation(
                    pixelIndex,
                    _random.GetInt(127),
                    _random.GetInt(127),
                    _random.GetInt(127),
                    startCount,
                    endCount);

            return item;
        }
        /// <summary>
        /// Do one animation step for a specific animation.
        /// </summary>
        /// <param name="animation">The animation.</param>
        public void DoAnimationStep(Animation animation)
        {
            int index = animation.LedNumber * 3;

            float greenCurrent = _colorValues[index];
            float redCurrent = _colorValues[index + 1];
            float blueCurrent = _colorValues[index + 2];

            if (animation.Current == 0)
            {
                animation.RedIncrement = (animation.RedTarget - redCurrent) / animation.Steps;
                animation.GreenIncrement = (animation.GreenTarget - greenCurrent) / animation.Steps;
                animation.BlueIncrement = (animation.BlueTarget - blueCurrent) / animation.Steps;
            }

            _colorValues[index] = greenCurrent + animation.GreenIncrement;
            _colorValues[index + 1] = redCurrent + animation.RedIncrement;
            _colorValues[index + 2] = blueCurrent + animation.BlueIncrement;
        }
        public void Ping()
        {
            _rgbStrip.ClearAll();

            for (int count = 0; count < 1000; count++)
            {
                if (count % 3 == 0)
                {
                    int pixelIndex = -1;

                    for (int i = 0; i < 10; i++)
                    {
                        int testIndex = _random.GetInt(NumPixels);
                        if (!_animator.IsPixelAnimating(testIndex))
                        {
                            pixelIndex = testIndex;
                            break;
                        }
                    }

                    if (pixelIndex != -1)
                    {
                        int dimSize = GetRandomDimSize();
                        int cycleCount = 120 / dimSize;

                        Animation item = GetItem(pixelIndex, _random.GetInt(7), 120, cycleCount);
                        Animation itemDown =
                            new Animation(pixelIndex, 0, 0, 0, cycleCount, cycleCount);

                        _animator.AddAnimation(item);
                        _animator.AddAnimation(itemDown);
                    }
                }

                _animator.DoAnimationStep();
            }
        }