mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
SvgExporter: Fix matrix conversion to rotate() command.
This commit is contained in:
parent
00f710b599
commit
eb0fb99b12
2 changed files with 7 additions and 2 deletions
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
text.rotate(45);
|
text.rotate(45);
|
||||||
text.shear(.85, .15);
|
text.shear(.85, .15);
|
||||||
text.scale(.85, .75);
|
text.scale(.85, 2);
|
||||||
|
|
||||||
var path2 = new Path.Circle(new Point(100, 100), 50);
|
var path2 = new Path.Circle(new Point(100, 100), 50);
|
||||||
path2.strokeColor = 'black';
|
path2.strokeColor = 'black';
|
||||||
|
|
|
@ -52,6 +52,11 @@ var SvgExporter = this.SvgExporter = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTransform(item) {
|
function getTransform(item) {
|
||||||
|
// Note, we're taking out the translation part of the matrix and move it
|
||||||
|
// to x, y attributes, to produce more readable markup, and not have to
|
||||||
|
// use center points in rotate(). To do so, SVG requries us to inverse
|
||||||
|
// transform the translation point by the matrix itself, since they are
|
||||||
|
// provided in local coordinates.
|
||||||
var matrix = item._matrix.createShiftless(),
|
var matrix = item._matrix.createShiftless(),
|
||||||
trans = matrix._inverseTransform(item._matrix.getTranslation()),
|
trans = matrix._inverseTransform(item._matrix.getTranslation()),
|
||||||
attrs = {
|
attrs = {
|
||||||
|
@ -68,7 +73,7 @@ var SvgExporter = this.SvgExporter = new function() {
|
||||||
scale = matrix.getScaling();
|
scale = matrix.getScaling();
|
||||||
if (angle != null) {
|
if (angle != null) {
|
||||||
transform.push(angle
|
transform.push(angle
|
||||||
? 'rotate(' + angle + ',' + formatPoint(center) +')'
|
? 'rotate(' + formatNumber(angle) + ')'
|
||||||
: 'scale(' + formatPoint(scale) +')');
|
: 'scale(' + formatPoint(scale) +')');
|
||||||
} else {
|
} else {
|
||||||
transform.push('matrix(' + matrix.getValues().join(',') + ')');
|
transform.push('matrix(' + matrix.getValues().join(',') + ')');
|
||||||
|
|
Loading…
Reference in a new issue