Merge pull request #1133 from openscad/svg-scaling-fix

Remove border from SVG viewport to fix scaling issues (fixes #1122).
master
Marius Kintel 2015-01-04 11:54:32 -05:00
commit d920a29a3e
1 changed files with 6 additions and 2 deletions

View File

@ -505,11 +505,15 @@ void export_svg(const Polygon2d &poly, std::ostream &output)
int miny = floor(-bbox.max().y());
int maxx = ceil(bbox.max().x());
int maxy = ceil(-bbox.min().y());
int width = maxx - minx;
int height = maxy - miny;
output
<< "<?xml version=\"1.0\" standalone=\"no\"?>\n"
<< "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
<< "<svg width=\"" << (maxx - minx) << "\" height=\"" << (maxy - miny) << "\" viewBox=\"" << (minx - 1) << " " << (miny - 1) << " " << (maxx - minx + 2) << " " << (maxy - miny + 2) << "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n"
<< "<svg width=\"" << width << "\" height=\"" << height
<< "\" viewBox=\"" << minx << " " << miny << " " << width << " " << height
<< "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n"
<< "<title>OpenSCAD Model</title>\n";
output << "<path d=\"\n";