UNPKG

@fetaoily/fabricjs-extra

Version:
30 lines (29 loc) 1.01 kB
/* eslint-disable */ module.exports = ({ fabric }) => { if (fabric.YxExtEraserBrush) { fabric.warn('fabric.YxExtEraserBrush is already defined'); return; } fabric.YxExtEraserBrush = fabric.util.createClass(fabric.PencilBrush, { createPath: function (pathData) { let path = new fabric.YxExtEraserPath(pathData, { fill: null, stroke: this.color, strokeWidth: this.width, strokeLineCap: this.strokeLineCap, strokeMiterLimit: this.strokeMiterLimit, strokeLineJoin: this.strokeLineJoin, strokeDashArray: this.strokeDashArray, }); let position = new fabric.Point(path.left + path.width / 2, path.top + path.height / 2); position = path.translateToGivenOrigin(position, 'center', 'center', path.originX, path.originY); path.top = position.y; path.left = position.x; if (this.shadow) { this.shadow.affectStroke = true; path.setShadow(this.shadow); } return path; } }); };