Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Fabric.js和Fabric-brush.js在绘图板上撤消和重做_Javascript_Fabricjs - Fatal编程技术网

Javascript 使用Fabric.js和Fabric-brush.js在绘图板上撤消和重做

Javascript 使用Fabric.js和Fabric-brush.js在绘图板上撤消和重做,javascript,fabricjs,Javascript,Fabricjs,我用Fabric.js和Fabric-brush.js开发了一个绘图板。当我添加撤销和重做功能时,它们不起作用。但当我不参考fabric-brush.js时,它们可以工作。那么,如何使用fabric-Brush.js和Undo和Redo功能一起实现喷涂笔刷功能呢 以下是它的JSFIDLE链接: 以下是参考资料: 1.https://jsfiddle.net/Fidel90/7kmf3jz2/ 2.https://codepen.io/keerotic/pen/yYXeaR 非常感谢 //undo

我用Fabric.js和Fabric-brush.js开发了一个绘图板。当我添加撤销和重做功能时,它们不起作用。但当我不参考fabric-brush.js时,它们可以工作。那么,如何使用fabric-Brush.js和Undo和Redo功能一起实现喷涂笔刷功能呢

以下是它的JSFIDLE链接:

以下是参考资料: 1.https://jsfiddle.net/Fidel90/7kmf3jz2/ 2.https://codepen.io/keerotic/pen/yYXeaR

非常感谢

//undo and redo
canvas.on('object:added', function() {
  if (!isRedoing) {
    h = [];
  }
  isRedoing = false;
});

var isRedoing = false;
var h = [];

function undo() {
  if (canvas._objects.length > 0) {
    h.push(canvas._objects.pop());
    canvas.renderAll();
  }
}

function redo() {

  if (h.length > 0) {
    isRedoing = true;
    canvas.add(h.pop());
  }
}
试试这个

导入订单

  • 织物
  • 织物刷
  • 织物历史

  • 谢谢你的帮助!但是fabric-brush.js在导入订单的演示中不起作用。