Exemple #1
0
        public override byte[] Render()
        {
            if (TimePassed(5))
            {
                if (FirstFrame)
                {
                    Image.SetAll(_bgcolor);
                }

                for (int i = 0; i < LedCount; i++)
                {
                    if (_pixelArray[i] > 256)
                    {
                        _pixelArray[i] = _pixelArray[i] - 500 / (256 - _speed) * 4 > 0 ? _pixelArray[i] - 500 / (256 - _speed) * 4 : 0;
                    }
                    else
                    {
                        _pixelArray[i] = _pixelArray[i] - 500 / (256 - _speed) > 0 ? _pixelArray[i] - 500 / (256 - _speed) : 0;
                    }
                }

                if (Rndm.Next(1000) < _count)
                {
                    var index = RndmIndex();
                    if (_pixelArray[index] < 0.1)
                    {
                        _pixelArray[index] = 510;
                    }
                }

                for (int i = 0; i < LedCount; i++)
                {
                    if (_pixelArray[i] != 0)
                    {
                        RgbColor newColor;

                        if (_pixelArray[i] > 255)
                        {
                            newColor = RgbColor.Transition(_color, _bgcolor, ((_pixelArray[i] - 255) + 1) / 256, _evenColors);
                        }
                        else
                        {
                            newColor = RgbColor.Transition(_bgcolor, _color, (_pixelArray[i] + 1) / 256, _evenColors);
                        }
                        Image.Leds[i] = newColor;
                    }
                    else
                    {
                        Image.Leds[i] = _bgcolor;
                    }
                }
                return(Image.ToByteArray());
            }
            return(null);
        }
Exemple #2
0
 protected int RndmIndex()
 {
     return(Rndm.Next((int)LedCount));
 }