我正在用jquery和fabric.js库构建一个画布。我使用代码设置叠加图像:
fabric.Image.fromURL('images/'+$_GET['id']+'.png', function(img) {
img.set({
left: (canvasW-img.width)/2,
top: (canvasH-img.height)/2
});
canvas2.setOverlayImage(img,canvas2.renderAll.bind(canvas2));
});
使用代码加载图片时添加:
fabric.Image.fromURL(e.target.result, function(img) {
img.set({
left: (canvasW-w)/2,
top: (canvasH-w*img.height/img.width)/2,
scaleX: w/img.width,
scaleY: w/img.width
});
canvas2.add(img);
canvas2.renderAll();
});
如果图像不在覆盖图像区域时,如何将图像的不透明度更改为0.5? 类似于:http://postimg.org/image/weyf480ep/