简体   繁体   中英

Is it possible to set background image in canvas HTML5 and can do some paint functionality like Undo,Erase,Clear,Save that background image?

I want to know about canvas HTML5. In my base canvas element i want to set background image,and on that i want to perform some functionality like in paint Erase,Undo,Clear and save that effected image(after applying all the effect undo,clear).. Any suggestion or example..

You can draw the Background to the canvas, by using drawImage(). All further Manipulations are painted ontop the Image.

When you hav finished your work you can Export your Canvasstate to an Image.

But you have to Hold a History for all task, because the canvas will be directly modified.

May be the Save and restore Method are helpful.

It is important, that you draw your image to the canvas first, so all other effects will affect the image.

最简单,最佳的性能实践是将背景作为div放在画布后面。

The history API can be used for undo and redo.

The toDataURL method of the Canvas object can be used to save an image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM