/// <summary> /// Plays the specified animation once. /// </summary> private async Task PlayOnce(Animation anim, CancellationToken cancelToken) { int i = 0; while (true) { for (int j = 0; j < leds.Length; j++) { if (leds.Length == anim.FrameLength) { leds[j].Color(anim[i][j]); } else { // Scaling animation to fit led count leds[j].Color(HSVColor.Black); int index = (int)Utils.Scale(j, 0, leds.Length, 0, anim.FrameLength); leds.AddColorToLedsAround(j, anim[i][index], 5); } } i++; if (cancelToken.IsCancellationRequested) { throw new TaskCanceledException(); } NewFrameReady.Invoke(this, this.leds); await Task.Delay(30); if (i == anim.FrameCount) { break; } } //currentlyRunningAnim = null; }