Canvas save status, canvas save status
1. Save and restore the drawing status:
When drawing a graphic, it is inevitable that a certain style will be repeatedly used, and sometimes switch back and forth between different colors.
To reduce code redundancy, we can call the save () method in the canvas to help us
Save some styles and attributes so that we can call the restore () method in the canvas to use these previously saved styles and attributes again!
The specific code is as follows:
<! DOCTYPE html>
2. Save and restore multiple drawing states:
How do I save multiple drawing states?
We can understand this: there is a photocopier that copies a large amount of data, and the first copy must be at the bottom, and then the last copy is tired, And then heap into a pile,
The top copy must be the last copy!
The storage status is similar to the operation status of the photocopier. The last storage is at the top!
Let's see how the code is implemented:
<! DOCTYPE html>
Communication Group: 225443677