Fabric.js:清除画布的背景颜色

时间:2014-06-27 17:05:57

标签: fabricjs

有没有人知道如何使用setBackgroundColor方法清除Fabric.js画布的背景颜色?

我基本上想要回到“无背景颜色模式”,因此它会显示背后的div。

1 个答案:

答案 0 :(得分:5)

您可以使用setBackgroundColor

canvas.setBackgroundColor('', canvas.renderAll.bind(canvas));

由于合并了拉取请求1445(https://github.com/kangax/fabric.js/pull/1445),您也可以将backgroundColor设置为null。

canvas.setBackgroundColor(null, canvas.renderAll.bind(canvas));