【发布时间】:2016-10-06 11:36:07
【问题描述】:
我在画布上制作了一个矩形的蒙版,我需要蒙版之外的任何东西的不透明度为 0.8,因此蒙版之外的所有对象都被视为不透明 请看一下小提琴。
http://jsfiddle.net/ZxYCP/637/
var img01URL = 'https://www.google.com/images/srpr/logo4w.png';
var img02URL = 'http://fabricjs.com/lib/pug.jpg';
var canvas = new fabric.Canvas('c');
canvas.clipTo = function(ctx) {
ctx.beginPath();
ctx.fillStyle = 'gray';
ctx.rect(180, 10, 200, 200);
ctx.fill();
ctx.closePath();
ctx.save();
}
canvas.controlsAboveOverlay = true;
canvas.renderAll();
var pugImg = new Image();
pugImg.onload = function(img) {
var pug = new fabric.Image(pugImg, {
angle: 45,
width: 500,
height: 500,
left: 230,
top: 50,
scaleX: 0.3,
scaleY: 0.3,
});
canvas.add(pug);
};
pugImg.src = img02URL;
【问题讨论】:
标签: javascript transparency fabricjs mask