mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-21 11:51:51 +00:00
fix pattern to svg (#3601)
This commit is contained in:
parent
d5220fee6e
commit
0c523361f5
2 changed files with 18 additions and 15 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
'<desc>Created with Fabric.js ', fabric.version, '</desc>\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(
|
||||
'<rect x="', this[property].offsetX, '" y="', this[property].offsetY, '" ',
|
||||
'<rect transform="translate(', this.width / 2, ',', this.height / 2, ')"',
|
||||
' x="', filler.offsetX - this.width / 2, '" y="', filler.offsetY - this.height / 2, '" ',
|
||||
'width="',
|
||||
(this[property].repeat === 'repeat-y' || this[property].repeat === 'no-repeat'
|
||||
? this[property].source.width
|
||||
(repeat === 'repeat-y' || repeat === 'no-repeat'
|
||||
? filler.source.width
|
||||
: this.width),
|
||||
'" height="',
|
||||
(this[property].repeat === 'repeat-x' || this[property].repeat === 'no-repeat'
|
||||
? this[property].source.height
|
||||
(repeat === 'repeat-x' || repeat === 'no-repeat'
|
||||
? filler.source.height
|
||||
: this.height),
|
||||
'" fill="url(#' + property.id + ')"',
|
||||
'" fill="url(#SVGID_' + filler.id + ')"',
|
||||
'></rect>\n'
|
||||
);
|
||||
}
|
||||
else if (this[property] && property === 'overlayColor') {
|
||||
else {
|
||||
markup.push(
|
||||
'<rect x="0" y="0" ',
|
||||
'width="', this.width,
|
||||
|
|
|
|||
Loading…
Reference in a new issue