Command Pattern for undo/redo in paint application

后端 未结 2 1227
时光取名叫无心
时光取名叫无心 2021-02-06 14:47

I would like to implement undo/redo in a small paint application. It seems the Command Pattern fits the use nicely, but I am unsure how to best implement it.

As I unders

2条回答
  •  情话喂你
    2021-02-06 15:20

    I would stick with command pattern and first try a naive solution (=the most memory-hungry). For some graphical operations it may be even necessary to keep a copy of the entire image in the command object (eg. think of filters). This is a common problem also in professional image editing applications, they often have a memory or step limit of last commands that are remembered. And if the memory consumption is really large you may think of swapping the oldest entries in command-history to file system. I think user will not mind waiting a second until the change is undone.

提交回复
热议问题