fabricjs删除backgroundImage [英] fabricjs delete backgroundImage
问题描述
是否可以在设置 或者回到标准背景?将 感谢您的帮助! 这是来自 显然,背景颜色实际上,当你做 所以,当你不想绘制 Is it possible to delete the backgroundImage in a Or just go back to the standard background? To set the Thanks for helping!
Greetings Max This is a snippet from Clearly, the background color is, in fact, being set to white when you do So, when you don't want the 这篇关于fabricjs删除backgroundImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! canvas.setBackgroundImage('img_url',function(){
canvas.renderAll();
backgroundColor
设置为 white
isn'
Greetings Max
renderAll
$的功能b $ b pre $ ...
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
,因为 typeof this.backgroundImage ==='object'
仍然评估为<$在 renderAll
中提示c $ c> true ,提示 backgroundImage
被绘制。它适用于 canvas.backgroundImage = 0;
,但是。 示例 。 fabric.Canvas
after setting with:canvas.setBackgroundImage('img_url',function() {
canvas.renderAll();
backgroundColor
to white
isn't working.renderAll
function of 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;
. But, since canvas.backgroundImage
is still an Image
object, it is drawn over whatever color you fill the background with.backgroundImage
to be drawn, you need to set it to 0
. It doesn't work with null
, since typeof this.backgroundImage === 'object'
still evaluates to true
in renderAll
, prompting backgroundImage
to be drawn. It works with canvas.backgroundImage = 0;
, though.