如何向HTML5 Canvas添加撤消功能? [英] How to add undo-functionality to HTML5 Canvas?

查看:149
本文介绍了如何向HTML5 Canvas添加撤消功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个草图应用程序在所有的HTML5和Javascript中完成,我想知道如何创建一个撤消按钮,所以你可以撤消你最后一件事。任何想法?

I have a Sketching app done in all HTML5 and Javascript, and I was wondering how I would create an Undo Button, so you could undo the last thing you drew. Any idea?

推荐答案

您必须将所有修改存储在数据结构中。然后,如果用户想要撤消,您可以删除最新的修改。然后再次从数据结构重绘所有绘图操作。

You have to store all modifications in a datastructure. Then you can delete the latest modification if the user wants to undo it. Then you repaint all drawing operations from your datastructure again.

这篇关于如何向HTML5 Canvas添加撤消功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆