Skip to content

Commit

Permalink
patch canvas color toSVG
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Apr 27, 2021
1 parent 910f14e commit 7fe1d1e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/mixins/eraser_brush.mixin.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7fe1d1e

Please sign in to comment.