Use Path#isPolygon() in SvgExporter.

This commit is contained in:
Jürg Lehni 2012-11-04 00:04:15 -07:00
parent 1050e3314e
commit e2cf7e1ace

View file

@ -17,12 +17,12 @@
* @author Stetson-Team-Alpha * @author Stetson-Team-Alpha
*/ */
/** /**
* @name SvgExporter * @name SvgExporter
* *
* @class The SvgExporter object holds all the functionality to convert a * @class The SvgExporter object holds all the functionality to convert a
* Paper.js DOM to a SVG DOM. * Paper.js DOM to a SVG DOM.
*/ */
var SvgExporter = this.SvgExporter = new function() { var SvgExporter = this.SvgExporter = new function() {
@ -343,23 +343,10 @@ var SvgExporter = this.SvgExporter = new function() {
var type; var type;
var dPoint12; var dPoint12;
var dPoint34; var dPoint34;
var straight = true;
var segHandleIn;
var segHandleOut;
// See if actually have any curves in the path. Differentiate // See if actually have any curves in the path. Differentiate
// between straight objects (line, polyline, rect, and polygon) and // between straight objects (line, polyline, rect, and polygon) and
// objects with curves(circle, ellipse, roundedRectangle). // objects with curves(circle, ellipse, roundedRectangle).
for( var i = 0, l = segArray.length; i < l && straight; i++) { if (path.isPolygon()) {
segHandleIn = segArray[i].getHandleIn();
segHandleOut = segArray[i].getHandleOut();
if (!segHandleIn.isZero() || !segHandleOut.isZero())
straight = false;
}
// Checks if the type of the passed in path is a rounded rectangle, an
// ellipse, a circle, or if it's simply a path.
// If there aren't any curves (straight == true), then check if the type
// is a rectangle, a polygon, a polyline, or simply a line.
if (straight) {
if (segArray.length == 4) { if (segArray.length == 4) {
// If the distance between (point0 and point1) and (point2 and // If the distance between (point0 and point1) and (point2 and
// point3) are equal, then it is a rectangle // point3) are equal, then it is a rectangle