是否可以删除背景图像fabric.Canvas
设置后:
canvas.setBackgroundImage('img_url',function() {
canvas.renderAll();
或者只是回到标准背景?要设置backgroundColor
to white
不工作。
感谢您的帮助!
问候最大
这是摘自renderAll
的函数fabric.Canvas
;
...
if (this.backgroundColor) {
canvasToDrawOn.fillStyle = this.backgroundColor;
canvasToDrawOn.fillRect(0, 0, this.width, this.height);
}
if (typeof this.backgroundImage === 'object') {
this._drawBackroundImage(canvasToDrawOn);
}
...
显然,当您这样做时,背景颜色实际上被设置为白色canvas.backgroundColor = white;
。但是由于canvas.backgroundImage
仍然是一个Image
对象,它会绘制在您填充背景的任何颜色上。
所以,当你不想要backgroundImage
要绘制,您需要将其设置为0
。它不适用于null
, since typeof this.backgroundImage === 'object'
仍然评估为true
in renderAll
, 提示backgroundImage
被绘制。它适用于canvas.backgroundImage = 0;
, 尽管。
Example http://jsfiddle.net/EQEBT/.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)