开发者

Saving the HTML Canvas Context Stack online?

开发者 https://www.devze.com 2023-02-17 00:47 出处:网络
Is there a simple way to save an HTML canvas stack for future manipulation? I do not want to save the canvas as an image because I need to be able to edit the canvas at any time.

Is there a simple way to save an HTML canvas stack for future manipulation?

I do not want to save the canvas as an image because I need to be able to edit the canvas at any time.

Ide开发者_如何转开发ally I would like to save the stack as a text file.


Canvas does not have any built in way to do this. You would have to write a custom layer in between your code and the canvas layer to track the state.

Off the top of my head, the Fabric canvas library has the ability to export the scene to JSON. See Element.toDatalessJSON() and Element.loadDatalessJSON(), which you can use on the root Fabric canvas element.

0

精彩评论

暂无评论...
验证码 换一张
取 消