BlinkStickDotNet.BlinkStick.Morph C# (CSharp) Method

Morph() public method

Morph from current color to new color on BlinkStick Pro.
public Morph ( byte channel, byte index, byte r, byte g, byte b, int duration = 1000, int steps = 50 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
r byte The red component.
g byte The green component.
b byte The blue component.
duration int How long should the morph last
steps int How many steps for color changes
return void
        public void Morph(byte channel, byte index, byte r, byte g, byte b, int duration=1000, int steps=50)
        {
            if (stopped)
                return;

            byte cr, cg, cb;
            GetColor(index, out cr, out cg, out cb);

            for (int i = 1; i <= steps; i++)
            {
                this.InternalSetColor(channel, index, 
                    (byte)(1.0 * cr + (r - cr) / 1.0 / steps * i), 
                    (byte)(1.0 * cg + (g - cg) / 1.0 / steps * i), 
                    (byte)(1.0 * cb + (b - cb) / 1.0 / steps * i));

                if (!WaitThread(duration / steps))
                    return;
            }
        }

Same methods

BlinkStick::Morph ( RgbColor color, int duration = 1000, int steps = 50 ) : void
BlinkStick::Morph ( byte channel, byte index, RgbColor color, int duration = 1000, int steps = 50 ) : void
BlinkStick::Morph ( byte r, byte g, byte b, int duration = 1000, int steps = 50 ) : void
BlinkStick::Morph ( byte channel, byte index, string color, int duration = 1000, int steps = 50 ) : void
BlinkStick::Morph ( string color, int duration = 1000, int steps = 50 ) : void