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_ */