Canvas save status, canvas save status

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.