Curtain Effect NeoPixel FastLED library

I'm trying to code a Curtain Effect for NeoPixel with the FastLED Library.

This is what I've managed so far:

void loop() { 
 FastLED.setBrightness(50);
  // curtain effect

 for(int i=0; i<=75; i++) {
            leds[i] = CRGB::Blue;
            FastLED.show();
            delay(30);
        }                               // the 75th LED will be Blue       
        
 for(int i=NUM_LEDS; i>75; i--) { 
            leds[i] = CRGB::Blue;
            FastLED.show();            
            delay(30);                  // the 76th LED will be Blue

            }

for(int i=75; i<=150; i++) {
            leds[i] = CRGB::Red;
            FastLED.show();
            delay(30);                // starting from LED #76, they will turn off oneoyone until the end
}          
 for(int i=75; i<=75; i--) { 
            leds[i] = CRGB::Red;
            FastLED.show();
            delay(30);               // starting from LED #75, they will turn off oneoyone until the start
        }
      
                      
}
  1. They all move separately. What would I need to do that the leds are filled in from both sides at the same time?

  2. The time until the next loop depends on the color. For Example, I count 8 seconds for Black, 5 if I choose Green and choosing Red repeats the loop after less than 1 second?? Does someone have an explanation?

Now after some research I discovered that some users suggest the use of an Array for this purpose. But I also found on a C++ tutorial website about loops that two variables are possible.

So I managed to modify the code to get the effect working

 FastLED.setBrightness(50);
  // curtain effect


 for(int i=0, j=NUM_LEDS; i<=NUM_LEDS/2 && j>=NUM_LEDS/2; i++, j--) {
            leds[i] = CRGB::Cyan;
            leds[j] = CRGB::Cyan;
            FastLED.show();
            delay(30);
        }                               // the 75th LED will be Cyan
          
 for(int i=NUM_LEDS/2, j=NUM_LEDS/2; i>=0, j<=NUM_LEDS; i--, j++) { 
            leds[i] = CRGB::Black;
            leds[j] = CRGB::Black;
            FastLED.show();
            delay(30);               // starting from LED #75, they will turn off onebyone until the start
        }
while(1){}

Now I want this to run only once, hence why I put while(1){} in it, but for my project it is supposed to be interrupted by Sensor data, PIR Motion Sensor to be precise. I wonder whether this is interruptable by an event