interrupting a for loop with button press

PaulS:
You have two choices. The first is to scrap all that code and start over. The loop() function loops. Let it handle all the looping. On any given pass through loop(), it may, or may not, be time to do something (such as change pixel number, etc.) or it may not.

You can, then, read the switch on every pass through loop(), resulting in nearly instantaneous recognition of switch presses.

Or, you can continue with that poor structure, and add poll the switch on every pass through every for loop, and break out of the for loop when the switch is pressed.

would it be possible to give me an example of how this might be structured if i used the loop() function? not sure how i would manage the switches between the different modes?