Rotating a Rectangle

I’m having trouble using rotate(). I want to draw a rotated rectangle on the map I have created. Everything on the map is relative to a vec2 called mapCenter that changes as the character moves around - so he stays in the center of the screen and the map moves around him. If I draw a rotated retangle like this…

rotate(45)
rect(mapCenter.x, mapCenter.y, 200, 100)
rotate(0)

…then it looks like it rotates any changes to mapCenter by 45 degrees as well because the rectangle meanders derpily when the character walks around, rather than staying stationary relative to the map. The documentation in Codea says the rotate applies to functions as well, but I didn’t think that applied here and would still use the values of whatever mapCenter was, despite how those values changed.

Is there any way to easily solve this or have I doomed myself by not taking this into account sooner?

@n0ogit Have you looked at pushStyle and popStyle, pushMatrix and popMatrix.

I’m familiar with pushStyle and popStyle, but not pushMatrix and popMatrix. It does sound like that’s what I need though. Thank you!