mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-28 23:08:17 +00:00
Fix pathGroup TransformMatrix
solves missing transformMatrix
This commit is contained in:
parent
498913ff8c
commit
0523352dfa
3 changed files with 23 additions and 2 deletions
|
|
@ -91,7 +91,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
|||
* @return {String}
|
||||
*/
|
||||
getSvgTransformMatrix: function() {
|
||||
return this.transformMatrix ? ' matrix(' + this.transformMatrix.join(' ') + ')' : '';
|
||||
return this.transformMatrix ? ' matrix(' + this.transformMatrix.join(' ') + ') ' : '';
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@
|
|||
//jscs:disable validateIndentation
|
||||
'<g ',
|
||||
'style="', this.getSvgStyles(), '" ',
|
||||
'transform="', translatePart, this.getSvgTransform(), '" ',
|
||||
'transform="', this.getSvgTransformMatrix(), translatePart, this.getSvgTransform(), '" ',
|
||||
'>\n'
|
||||
//jscs:enable validateIndentation
|
||||
];
|
||||
|
|
|
|||
|
|
@ -30,6 +30,16 @@
|
|||
'paths': getPathObjects()
|
||||
};
|
||||
|
||||
var REFERENCE_PATH_GROUP_SVG = '<g style="stroke: none; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: none; fill-rule: nonzero; opacity: 1;" transform="translate(0 0)" >\n' +
|
||||
'<path d="M 100 100 L 300 100 L 200 300 z" style="stroke: blue; stroke-width: 3; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,0,0); fill-rule: nonzero; opacity: 1;" transform="" stroke-linecap="round" />\n' +
|
||||
'<path d="M 200 200 L 100 200 L 400 50 z" style="stroke: blue; stroke-width: 3; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,0,0); fill-rule: nonzero; opacity: 1;" transform="" stroke-linecap="round" />\n' +
|
||||
'</g>\n';
|
||||
|
||||
var REFERENCE_PATH_GROUP_SVG_WITH_MATRIX = '<g style="stroke: none; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: none; fill-rule: nonzero; opacity: 1;" transform=" matrix(1 2 3 4 5 6) translate(0 0)" >\n' +
|
||||
'<path d="M 100 100 L 300 100 L 200 300 z" style="stroke: blue; stroke-width: 3; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,0,0); fill-rule: nonzero; opacity: 1;" transform="" stroke-linecap="round" />\n' +
|
||||
'<path d="M 200 200 L 100 200 L 400 50 z" style="stroke: blue; stroke-width: 3; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,0,0); fill-rule: nonzero; opacity: 1;" transform="" stroke-linecap="round" />\n' +
|
||||
'</g>\n';
|
||||
|
||||
function getPathElement(path) {
|
||||
var el = fabric.document.createElement('path');
|
||||
el.setAttribute('d', path);
|
||||
|
|
@ -221,4 +231,15 @@
|
|||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest('toSVG', function() {
|
||||
ok(fabric.PathGroup);
|
||||
getPathGroupObject(function(pathGroup) {
|
||||
ok(typeof pathGroup.toSVG == 'function');
|
||||
equal(pathGroup.toSVG(), REFERENCE_PATH_GROUP_SVG);
|
||||
pathGroup.transformMatrix = [1, 2, 3, 4, 5, 6];
|
||||
equal(pathGroup.toSVG(), REFERENCE_PATH_GROUP_SVG_WITH_MATRIX);
|
||||
start();
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue