<canvas id="myCanvas" width="800px" height="800px"></canvas>
<script>
let canvas=new fabric.Canvas('myCanvas')
let svgSrc='../img/shi.svg'
fabric.Image.fromURL(svgSrc,function(img){
img.set({
scaleX:1,
scaleY:1
//width:100,
//height:100
})
canvas.add(img);
var filter = new fabric.Image.filters.BlendColor({
color:'red',
mode: 'tint',
alpha: 1
});
img.filters.push(filter);
img.applyFilters();
canvas.renderAll();
},{
crossOrigin:'null'
})
</script>
更改
直接设置set更改没有用,不知道问题出在哪里
obj.filters=[];
var filter = new fabric.Image.filters.BlendColor({
color:color,
mode: "tint",
alpha: 1
});
obj.filters.push(filter)
obj.applyFilters();
网友评论