1.钢笔橡皮绘制
钢笔
this.fabricObj.freeDrawingBrush = new fabric.PencilBrush( this.fabricObj ); //钢笔刷
this.fabricObj.freeDrawingBrush.width = this.lineWidth; //线宽
this.fabricObj.isDrawingMode = true; //自由绘制
橡皮
this.fabricObj.freeDrawingBrush = new fabric.EraserBrush( this.fabricObj);
this.fabricObj.freeDrawingBrush.width = this.lineWidth;
this.fabricObj.isDrawingMode = true;
透明色
this.fabricObj.freeDrawingBrush自身无opacity属性,但是color属性可以用rgba属性,将hex转为rgba
hexToRgba(hex, opacity) {
return ( "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," +
parseInt("0x" + hex.slice(5, 7)) +"," + opacity + ")"
);
},
2.钢笔橡皮还原问题
看生成数据&