mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-18 05:00:58 +00:00
toSVG now displays flipped objects correctly. Fix #297. Version 0.9.18.
This commit is contained in:
parent
17fe1a2929
commit
5998dfc1a5
6 changed files with 53 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.9.17" };
|
||||
var fabric = fabric || { version: "0.9.18" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
|
|||
31
dist/all.js
vendored
31
dist/all.js
vendored
|
|
@ -1,7 +1,7 @@
|
|||
/* build: `node build.js modules=ALL` */
|
||||
/*! Fabric.js Copyright 2008-2012, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.9.17" };
|
||||
var fabric = fabric || { version: "0.9.18" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
@ -8074,12 +8074,29 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
|
|||
getSvgTransform: function() {
|
||||
var angle = this.getAngle();
|
||||
var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
|
||||
return [
|
||||
"translate(", toFixed(this.left, NUM_FRACTION_DIGITS), " ", toFixed(this.top, NUM_FRACTION_DIGITS), ")",
|
||||
angle !== 0 ? (" rotate(" + toFixed(angle, NUM_FRACTION_DIGITS) + ")") : '',
|
||||
(this.scaleX === 1 && this.scaleY === 1) ? '' : (" scale(" + toFixed(this.scaleX, NUM_FRACTION_DIGITS) +
|
||||
" " + toFixed(this.scaleY, NUM_FRACTION_DIGITS) + ")")
|
||||
].join('');
|
||||
|
||||
var translatePart = "translate(" +
|
||||
toFixed(this.left, NUM_FRACTION_DIGITS) +
|
||||
" " +
|
||||
toFixed(this.top, NUM_FRACTION_DIGITS) +
|
||||
")";
|
||||
|
||||
var anglePart = angle !== 0
|
||||
? (" rotate(" + toFixed(angle, NUM_FRACTION_DIGITS) + ")")
|
||||
: '';
|
||||
|
||||
var scalePart = (this.scaleX === 1 && this.scaleY === 1)
|
||||
? '' :
|
||||
(" scale(" +
|
||||
toFixed(this.scaleX, NUM_FRACTION_DIGITS) +
|
||||
" " +
|
||||
toFixed(this.scaleY, NUM_FRACTION_DIGITS) +
|
||||
")");
|
||||
|
||||
var flipXPart = this.flipX ? "matrix(-1 0 0 1 0 0) " : "";
|
||||
var flipYPart = this.flipY ? "matrix(1 0 0 -1 0 0)" : "";
|
||||
|
||||
return [ translatePart, anglePart, scalePart, flipXPart, flipYPart ].join('');
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
8
dist/all.min.js
vendored
8
dist/all.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
dist/all.min.js.gz
vendored
BIN
dist/all.min.js.gz
vendored
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "fabric",
|
||||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
|
||||
"version": "0.9.17",
|
||||
"version": "0.9.18",
|
||||
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
||||
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
|
||||
"repository": "git://github.com/kangax/fabric.js",
|
||||
|
|
|
|||
|
|
@ -364,12 +364,29 @@
|
|||
getSvgTransform: function() {
|
||||
var angle = this.getAngle();
|
||||
var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
|
||||
return [
|
||||
"translate(", toFixed(this.left, NUM_FRACTION_DIGITS), " ", toFixed(this.top, NUM_FRACTION_DIGITS), ")",
|
||||
angle !== 0 ? (" rotate(" + toFixed(angle, NUM_FRACTION_DIGITS) + ")") : '',
|
||||
(this.scaleX === 1 && this.scaleY === 1) ? '' : (" scale(" + toFixed(this.scaleX, NUM_FRACTION_DIGITS) +
|
||||
" " + toFixed(this.scaleY, NUM_FRACTION_DIGITS) + ")")
|
||||
].join('');
|
||||
|
||||
var translatePart = "translate(" +
|
||||
toFixed(this.left, NUM_FRACTION_DIGITS) +
|
||||
" " +
|
||||
toFixed(this.top, NUM_FRACTION_DIGITS) +
|
||||
")";
|
||||
|
||||
var anglePart = angle !== 0
|
||||
? (" rotate(" + toFixed(angle, NUM_FRACTION_DIGITS) + ")")
|
||||
: '';
|
||||
|
||||
var scalePart = (this.scaleX === 1 && this.scaleY === 1)
|
||||
? '' :
|
||||
(" scale(" +
|
||||
toFixed(this.scaleX, NUM_FRACTION_DIGITS) +
|
||||
" " +
|
||||
toFixed(this.scaleY, NUM_FRACTION_DIGITS) +
|
||||
")");
|
||||
|
||||
var flipXPart = this.flipX ? "matrix(-1 0 0 1 0 0) " : "";
|
||||
var flipYPart = this.flipY ? "matrix(1 0 0 -1 0 0)" : "";
|
||||
|
||||
return [ translatePart, anglePart, scalePart, flipXPart, flipYPart ].join('');
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue