I still have an impression you haven't figured out howIs there a way to get the rect() to be rendered before the draw() is complete?
& especially when Processing renders a screen frame!
Every drawing you do is actually stored inside a PGraphics instance kept by variable g.
This is called a screen or blit buffer.
Only when draw() is finished, Processing calls a hidden function called run(),
which is therefore tasked to render a screen frame based on that PGraphics most current state!
What it means is that if you draw something that gets in the way of another drawing,
no 1 will notice that happening, for the screen stays still until the end of draw()!
Here's a post which dealt w/ something similar to yours:
http://forum.processing.org/topic/saveframe-only-capturing-background-image