I’m assuming that code is in your draw() loop correct?
First of all it’s worth learning how the draw() loop actually works. Draw is called once per frame and at the end of the draw loop anything you’ve drawn is displayed on the screen. This means that if I draw a red rectangle across the whole screen and a then a green rectangle across the whole screen after that I will only see the green rectangle as the red one is drawn over.
the ofSleepMillis() method will cause your whole application to sleep so basically what you’re doing with your code is:
Drawing a rectangle across the whole frame buffer
Pausing everything
Setting the color to white
Drawing a rectangle across the whole frame buffer
setting the color to white
Drawing everything to the screen
Instead I would recommend using a timer rather than an ofSleepMillis() method.
To do this you can use ofGetElapsedTimef() to get the current time and swap between the two colors each x millis based on the knob value.
So something like this should work:
in ofApp.h:
// Define a variable for timing
float lastTimeSwapped = 0;
// Define a variable for keeping track of your color
bool colorOneOn= true;