From 7fe1d1edc914be9179431278c8020007a7f0d910 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Tue, 27 Apr 2021 08:01:32 +0300 Subject: [PATCH] patch canvas color toSVG --- src/mixins/eraser_brush.mixin.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/mixins/eraser_brush.mixin.js b/src/mixins/eraser_brush.mixin.js index 7ce118ffe2b..03219ed4731 100644 --- a/src/mixins/eraser_brush.mixin.js +++ b/src/mixins/eraser_brush.mixin.js @@ -1,6 +1,7 @@ (function () { var __setBgOverlayColor = fabric.StaticCanvas.prototype.__setBgOverlayColor; var ___setBgOverlay = fabric.StaticCanvas.prototype.__setBgOverlay; + var __setSVGBgOverlayColor = fabric.StaticCanvas.prototype._setSVGBgOverlayColor; fabric.util.object.extend(fabric.StaticCanvas.prototype, { backgroundColor: undefined, overlayColor: undefined, @@ -58,6 +59,23 @@ } }, + /** + * patch serialization + * background/overlay properties could be objects if parsed by this mixin or could be legacy values + * @private + */ + _setSVGBgOverlayColor: function (markup, property, reviver) { + var filler = this[property + 'Color']; + if (filler && typeof filler === 'object' && filler.type === 'rect') { + var excludeFromExport = filler.excludeFromExport || (this[property] && this[property].excludeFromExport); + if (filler && !excludeFromExport && filler.toSVG) { + markup.push(filler.toSVG(reviver)); + } + } else { + __setSVGBgOverlayColor.call(this, markup, property, reviver); + } + }, + /** * @private * @param {CanvasRenderingContext2D} ctx Context to render on