我使用此代码在FabricJS中剪辑画布:
var mask='<svg width="760" height="406" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><g><ellipse fill="#c2c2C2" stroke-width="0" stroke-dasharray="null" stroke-linejoin="null" stroke-linecap="null" cx="380.00004" cy="203.00001" id="svg_1" rx="375.11113" ry="198.22223" stroke="null"/></g></svg>';
var canvas=new fabric.Canvas("canvas");
fabric.loadSVGFromString(mask, function(objects, options) {
var loadedObject = fabric.util.groupSVGElements(objects, options);
loadedObject.set({left:0,top:0});
canvas.clipTo = function(ctx) {
loadedObject.render(ctx);
};
canvas.renderAll();
});
我只希望裁剪图纸而不剪裁色带图片。
谢谢