From 0c523361f5e3305a52e38f5af96ef7b7ca4c6bbc Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Mon, 2 Jan 2017 01:33:17 +0100 Subject: [PATCH] fix pattern to svg (#3601) --- src/pattern.class.js | 8 ++++---- src/static_canvas.class.js | 25 ++++++++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/pattern.class.js b/src/pattern.class.js index 8467bc8c..11c19323 100644 --- a/src/pattern.class.js +++ b/src/pattern.class.js @@ -109,10 +109,10 @@ */ toSVG: function(object) { var patternSource = typeof this.source === 'function' ? this.source() : this.source, - patternWidth = patternSource.width / object.getWidth(), - patternHeight = patternSource.height / object.getHeight(), - patternOffsetX = this.offsetX / object.getWidth(), - patternOffsetY = this.offsetY / object.getHeight(), + patternWidth = patternSource.width / object.width, + patternHeight = patternSource.height / object.height, + patternOffsetX = this.offsetX / object.width, + patternOffsetY = this.offsetY / object.height, patternImgSrc = ''; if (this.repeat === 'repeat-x' || this.repeat === 'no-repeat') { patternHeight = 1; diff --git a/src/static_canvas.class.js b/src/static_canvas.class.js index 57b1e5c8..7969ee41 100644 --- a/src/static_canvas.class.js +++ b/src/static_canvas.class.js @@ -1204,9 +1204,6 @@ 'version="1.1" ', 'width="', width, '" ', 'height="', height, '" ', - (this.backgroundColor && !this.backgroundColor.toLive - ? 'style="background-color: ' + this.backgroundColor + '" ' - : null), viewBox, 'xml:space="preserve">\n', 'Created with Fabric.js ', fabric.version, '\n', @@ -1324,22 +1321,28 @@ * @private */ _setSVGBgOverlayColor: function(markup, property) { - if (this[property] && this[property].source) { + var filler = this[property]; + if (!filler) { + return; + } + if (filler.toLive) { + var repeat = filler.repeat; markup.push( - '\n' ); } - else if (this[property] && property === 'overlayColor') { + else { markup.push( '