HTML5 Canvas : State Management
HTML5 canvas provides Save
and restore
methods to draw complex graphics.
It can save the state of canvas, including the translation, zooming, rotation, miscutting, cropping and other operations of canvas, and can also restore to the last saved state.
Related methods:
//Save the status of the current environment
context.save()
//Return to previously saved path status and properties
context.restore()
The status of canvas is stored in memory. Its data structure is similar to stack, that is, it conforms to the basic characteristics of "first in, then out, then in, first out".