mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-21 03:41:52 +00:00
Update pattern.class.js
Added hack to support repeat and offset to svg export.
This commit is contained in:
parent
cac97b0a9b
commit
e3f479ceb9
1 changed files with 13 additions and 6 deletions
|
|
@ -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 '<pattern id="SVGID_' + this.id +
|
||||
'" x="' + this.offsetX +
|
||||
'" y="' + this.offsetY +
|
||||
'" x="' + patternOffsetX +
|
||||
'" y="' + patternOffsetY +
|
||||
'" width="' + patternWidth +
|
||||
'" height="' + patternHeight + '">' +
|
||||
'" height="' + patternHeight + '">\n' +
|
||||
'<image x="0" y="0"' +
|
||||
' width="' + patternSource.width +
|
||||
'" height="' + patternSource.height +
|
||||
'" xlink:href="' + patternImgSrc +
|
||||
'"></image>' +
|
||||
'</pattern>';
|
||||
'"></image>\n' +
|
||||
'</pattern>\n';
|
||||
},
|
||||
/* _TO_SVG_END_ */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue