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..
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
The easiest and best perfomance practise would be to put that background as a div behind the canvas.
回答3:
The history API can be used for undo and redo.
The toDataURL method of the Canvas object can be used to save an image.