我有2個矩形。當小矩形移動到較大矩形的外部時,我希望邊界外的小矩形區域不可見。防止Fabric JS對象可見邊界
如果小矩形的一半在裏面,一半在外面。然後只有一半可見,這example這樣工作。
我該如何做到這一點?
(function() {
var canvas = this.__canvas = new fabric.Canvas('canvas');
fabric.Object.prototype.transparentCorners = false;
// create a rectangle with a fill and a different color stroke
var rect = new fabric.Rect({
left: 50,
top: 50,
width: 150,
height: 250,
fill: 'transparent',
stroke: 'rgba(34,177,76,1)',
strokeWidth: 1
});
var rect2 = new fabric.Rect({
left: 50,
top: 50,
width: 50,
height: 50,
fill: 'rgba(34,50,100,1)',
stroke: 'rgba(34,177,76,1)',
strokeWidth: 1
});
canvas.add(rect);
canvas.add(rect2);
})();
例這裏可與這樣:
@ moáois不,我會用1.7.9實際上,我會更新jsfiddle – HOY