From daeb0e84305345b5e22721f3f1d3df1082313e0e Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Fri, 30 Oct 2009 03:18:54 -0800 Subject: [PATCH] Oops, was always writing SVG or EPS arcs counter-clockwise; which breaks with the new path stuff, since circular holes really do have to go ccw. So fix that. [git-p4: depot-paths = "//depot/solvespace/": change = 2062] --- exportvector.cpp | 22 +++++++++------------- wishlist.txt | 1 - 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/exportvector.cpp b/exportvector.cpp index f4f0176e..75245bf8 100644 --- a/exportvector.cpp +++ b/exportvector.cpp @@ -231,16 +231,13 @@ void EpsFileWriter::Bezier(SBezier *sb) { double theta0 = atan2(p0.y - c.y, p0.x - c.x), theta1 = atan2(p1.y - c.y, p1.x - c.x), dtheta = WRAP_SYMMETRIC(theta1 - theta0, 2*PI); - if(dtheta < 0) { - SWAP(double, theta0, theta1); - SWAP(Vector, p0, p1); - } MaybeMoveTo(p0, p1); fprintf(f, -" %.3f %.3f %.3f %.3f %.3f arc\r\n", +" %.3f %.3f %.3f %.3f %.3f %s\r\n", MmToPts(c.x - ptMin.x), MmToPts(c.y - ptMin.y), MmToPts(r), - theta0*180/PI, theta1*180/PI); + theta0*180/PI, theta1*180/PI, + dtheta < 0 ? "arcn" : "arc"); } else if(sb->deg == 3 && !sb->IsRational()) { MaybeMoveTo(sb->ctrl[0], sb->ctrl[3]); fprintf(f, @@ -535,15 +532,14 @@ void SvgFileWriter::Bezier(SBezier *sb) { theta1 = atan2(p1.y - c.y, p1.x - c.x), dtheta = WRAP_SYMMETRIC(theta1 - theta0, 2*PI); // The arc must be less than 180 degrees, or else it couldn't have - // been represented as a single rational Bezier. And arrange it - // to run counter-clockwise, which corresponds to clockwise in - // SVG's mirrored coordinate system. - if(dtheta < 0) { - SWAP(Vector, p0, p1); - } + // been represented as a single rational Bezier. So large-arc-flag + // must be false. sweep-flag is determined by the sign of dtheta. + // Note that clockwise and counter-clockwise are backwards in SVG's + // mirrored csys. MaybeMoveTo(p0, p1); - fprintf(f, "A%.3f,%.3f 0 0,0 %.3f,%.3f ", + fprintf(f, "A%.3f,%.3f 0 0,%d %.3f,%.3f ", r, r, + (dtheta < 0) ? 1 : 0, p1.x - ptMin.x, ptMax.y - p1.y); } else if(!sb->IsRational()) { if(sb->deg == 2) { diff --git a/wishlist.txt b/wishlist.txt index 5f618d49..7a9edd03 100644 --- a/wishlist.txt +++ b/wishlist.txt @@ -2,7 +2,6 @@ multi-drag select loop, all in group, others copy and paste -filled contours for export background image associative entities from solid model, as a special group