From 16de863aa526339fb1cea572747f9e30b97d3cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 6 Nov 2012 11:26:00 -0800 Subject: [PATCH] SvgExporter: Some more work on determineAngle(). --- src/svg/SvgExporter.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/svg/SvgExporter.js b/src/svg/SvgExporter.js index 92f13325..ca4e686a 100644 --- a/src/svg/SvgExporter.js +++ b/src/svg/SvgExporter.js @@ -119,7 +119,8 @@ var SvgExporter = this.SvgExporter = new function() { function determineAngle(path, segments, type, center) { // If the object is a circle, ellipse, rectangle, or rounded rectangle, - // see if they are placed at an angle. + // see if it is placed at an angle, by figuring out its topCenter point + // and measuring the angle to its center. var topCenter = type === 'rect' ? segments[1]._point.add(segments[2]._point).divide(2) : type === 'roundrect' @@ -127,11 +128,8 @@ var SvgExporter = this.SvgExporter = new function() { : type === 'circle' || type === 'ellipse' ? segments[1]._point : null; - if (topCenter) { - var angle = topCenter.subtract(center).getAngle() + 90; - return Numerical.isZero(angle) ? 0 : angle; - } - return 0; + var angle = topCenter && topCenter.subtract(center).getAngle() + 90; + return Numerical.isZero(angle || 0) ? 0 : angle; } function determineType(path, segments) {