Reset AffineTransform?

So the documentation for Graphics::addTransform says that it’ll apply a transform to all graphics operations following the call. How do we clear this transformation?
g.addTransform( AffineTransform() ) ?

I just looked at the documentation, it’s definitely weird that there’s no way to get/modify the context’s transform after adding to it. My suggestion would be to build up your transform as an AffineTransform object separate from your context (in this example, say we call it transform), then right before drawing the thing you need transformed call g.addTransform(transform), do your draw operations, then call g.addTransform(transform.inverted()) which will undo that transform in the context.

The cleanest would be IMHO before altering call a Graphics::saveState() and afterwards a Graphics::restoreState()

While browsing the docs, there’s something supercool: Graphics::ScopedSaveState as I understand it, simply instanciate a ScopedSaveState at the beginning of your block… I got to try that :slight_smile:

I used this a lot and I can confirm it works exactly like that. Super-convenient!

Awesome, I’ve never seen that. Thanks for sharing daniel!!