Pouknouki

Sauvegarde animation

Apr 11th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | None | 0 0
  1.  
  2.   if (transitionTime == 0 && animation != A_NoAnimation)
  3.   {
  4.     Serial.println("[E] Only A_NoAnimation can be used with a null transition time.");
  5.     return;
  6.   }
  7.  
  8.   switch (animation)
  9.   {
  10.     case A_Flash:
  11.       // Flash should always be used from full-black.
  12.       for (int i = 0; i < _PIXELS; i++)
  13.         strip.SetPixelColor(i, _BLACK);
  14.       strip.Show();
  15.  
  16.       for (int i = 0; i < _PIXELS; i++)
  17.       {
  18.         //      AnimEaseFunction easing;
  19.         //      easing = NeoEase::QuadraticIn;
  20.         AnimUpdateCallback animUpdate = [ = ](const AnimationParam & param)
  21.         {
  22.           RgbColor updatedColor = RgbColor::LinearBlend(_BLACK, targetColor, param.progress);
  23.           strip.SetPixelColor(param.index, updatedColor);
  24.         };
  25.         animations.StartAnimation(i, transitionTime, animUpdate);
  26.       }
  27.  
  28.       break;
  29.  
  30.     case A_LinearBlend:
  31.       for (int i = 0; i < _PIXELS; i++)
  32.       {
  33.         RgbColor originalColor = strip.GetPixelColor(i);
  34.         AnimEaseFunction easing;
  35.         easing = NeoEase::QuadraticIn;
  36.  
  37.         AnimUpdateCallback animUpdate = [ = ](const AnimationParam & param)
  38.         {
  39.           RgbColor updatedColor = RgbColor::LinearBlend(originalColor, targetColor, param.progress);
  40.           strip.SetPixelColor(param.index, updatedColor);
  41.         };
  42.         animations.StartAnimation(i, transitionTime, animUpdate);
  43.       }
  44.       break;
  45.  
  46.     case A_NoAnimation:
  47.       for (int i = 0; i < _PIXELS; i++)
  48.       {
  49.         strip.SetPixelColor(i, targetColor);
  50.       }
  51.       strip.Show();
  52.       break;
  53.  
  54.     default:
  55.       Serial.println("[!] No animation type defined.");
  56.       break;
  57.   }
Advertisement
Add Comment
Please, Sign In to add comment