Save and Restore
Explore how to effectively manage drawing states and transformations in Pycairo using save and restore methods. Learn to encapsulate complex drawing operations and reverse transforms safely to maintain consistent graphics context.
We'll cover the following...
We'll cover the following...
In one of the previous lessons, we learned to apply several transforms. But how do we remove the transforms, after we are done using them?
Reverse a transformation
It is possible to reverse a transform, by applying the inverse transform. For example, if we apply a translation (a, b), we can reverse it by applying a second translation (-a, -b), which puts us back where we started. We can reverse a scaling factor s, by applying a second scaling factor of 1/s. We can also reverse a rotation through an angle ...