shdowmyst

Untitled

Oct 30th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. void AnimateAndFill() {
  2.  
  3.   static uint8_t FrameCounter = 0;  //counts frame for steps measure.
  4.   uint8_t AnimationIndex;
  5.   uint8_t AnimationAndSpeed;
  6.  
  7.   // Effect speed global, nudges everything from left to right!
  8.   static int effectSpeed = 0;  //animation speed, This is not the speed you want to set. use SpeedIndex!
  9.  
  10.   // NoiseDistanceJump += 5;  // beatsin8(10,1,4);  //noise movement speed: bpm,lowest,highest.  
  11.  
  12.     if (0 < SpeedIndex && SpeedIndex < 20) {
  13.     if(FrameCounter % (20 - SpeedIndex) == 0 ) //slowing down animation by waiting x frames with the update. So, speedIndex 1 means wait 20 frames before incrase step.
  14.     { effectSpeed++; FrameCounter = 0; }
  15.   }
  16.   else if (SpeedIndex >= 20) {
  17.   effectSpeed += SpeedIndex - 19;
  18.   }
  19.   FrameCounter++;
  20.  
  21.  
  22.   for( int i = 0; i < NUM_LEDS; i++) {
  23.  
  24.  
  25.   switch (AnimationMethod) {
  26.   case 0: AnimationIndex = 0; break;
  27.   case 1: AnimationIndex = inoise8(i*AnimScale,NoiseDistanceJump+i*AnimScale) % 255; break;
  28.   case 2: AnimationIndex = sin8((i+SineOnePhase)*SineOneWaveLenght)*SineOneAmplitude + sin8((i+SineTwoPhase)*SineTwoWaveLenght)*SineTwoAmplitude; break;
  29.   }
  30.  
  31.     if(Reverse) {AnimationAndSpeed = AnimationIndex - effectSpeed;}
  32.       else  {AnimationAndSpeed = AnimationIndex + effectSpeed;}
  33.    
  34.       leds[i] = ColorFromPalette(CostumPalette, AnimationAndSpeed, 255);
  35.       }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment