SvgExporter: Some more work on determineAngle().

This commit is contained in:
Jürg Lehni 2012-11-06 11:26:00 -08:00
parent 4c463eb1f1
commit 16de863aa5

View file

@ -119,7 +119,8 @@ var SvgExporter = this.SvgExporter = new function() {
function determineAngle(path, segments, type, center) { function determineAngle(path, segments, type, center) {
// If the object is a circle, ellipse, rectangle, or rounded rectangle, // 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' var topCenter = type === 'rect'
? segments[1]._point.add(segments[2]._point).divide(2) ? segments[1]._point.add(segments[2]._point).divide(2)
: type === 'roundrect' : type === 'roundrect'
@ -127,11 +128,8 @@ var SvgExporter = this.SvgExporter = new function() {
: type === 'circle' || type === 'ellipse' : type === 'circle' || type === 'ellipse'
? segments[1]._point ? segments[1]._point
: null; : null;
if (topCenter) { var angle = topCenter && topCenter.subtract(center).getAngle() + 90;
var angle = topCenter.subtract(center).getAngle() + 90; return Numerical.isZero(angle || 0) ? 0 : angle;
return Numerical.isZero(angle) ? 0 : angle;
}
return 0;
} }
function determineType(path, segments) { function determineType(path, segments) {