Undoing Transforms

This may be the part you have been eagerly waiting for. As you probably realized by now, transforming the canvas isn’t an operation that resets itself with each thing you draw. It’s not like a fillStyle or strokeStyle. The transformation is always there for any draw operation you perform in the future. That isn’t always desirable, right?

To handle this, you need to explicitly turn the transforms off. There are several ways you can do with this. We’ll look at two approaches in this section and focus on a slightly different (and heavy-handed) approach in a future tutorial where we look at how to save and restore state.

Resetting the Transform…the Easy Way

The easiest way to reset a transform is to call the resetTransform method:

Get hands-on with 1200+ tech skills courses.