From e3f479ceb9ae62a23ec9624d6fdb5a3a2a76f921 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 26 Oct 2014 18:49:00 +0100 Subject: [PATCH] Update pattern.class.js Added hack to support repeat and offset to svg export. --- src/pattern.class.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/pattern.class.js b/src/pattern.class.js index 7d1cb04c..01766488 100644 --- a/src/pattern.class.js +++ b/src/pattern.class.js @@ -104,8 +104,15 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */ 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(), patternImgSrc = ''; - + if (this.repeat === 'repeat-x' || this.repeat === 'no-repeat') { + patternHeight = 1; + } + if (this.repeat === 'repeat-y' || this.repeat === 'no-repeat') { + patternWidth = 1; + } if (patternSource.src) { patternImgSrc = patternSource.src; } @@ -114,16 +121,16 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */ } return '' + + '" height="' + patternHeight + '">\n' + '' + - ''; + '">\n' + + '\n'; }, /* _TO_SVG_END_ */