diff --git a/web/app/sketcher/io.js b/web/app/sketcher/io.js
index ac502f9e..94288f0e 100644
--- a/web/app/sketcher/io.js
+++ b/web/app/sketcher/io.js
@@ -293,6 +293,13 @@ TCAD.io.PrettyColors = function() {
}
}
+TCAD.io.TextBuilder = function() {
+ this.data = "";
+ this.line = function (chunk, args) {
+ this.data += TCAD.io._format(chunk, args) + "\n"
+ }
+}
+
TCAD.io.BBox = function() {
var bbox = [Number.MAX_VALUE, Number.MAX_VALUE, - Number.MAX_VALUE, - Number.MAX_VALUE];
@@ -337,11 +344,7 @@ TCAD.io.BBox = function() {
TCAD.IO.prototype.svgExport = function () {
var T = TCAD.io.Types;
- var svg = "";
-
- function append(chunk, args) {
- svg += TCAD.io._format(chunk, args) + "\n"
- }
+ var out = new TCAD.io.TextBuilder();
var bbox = new TCAD.io.BBox();
@@ -356,28 +359,28 @@ TCAD.IO.prototype.svgExport = function () {
var layer = layers[l];
if (layer.readOnly) continue;
var color = prettyColors.next();
- append('', [layer.name, "none", color, '2']);
+ out.line('', [layer.name, "none", color, '2']);
for (var i = 0; i < layer.objects.length; ++i) {
var obj = layer.objects[i];
if (obj._class !== T.END_POINT) bbox.check(obj);
if (obj._class === T.SEGMENT) {
- append('', [obj.a.x, obj.a.y, obj.b.x, obj.b.y]);
+ out.line('', [obj.a.x, obj.a.y, obj.b.x, obj.b.y]);
} else if (obj._class === T.ARC) {
a.set(obj.a.x - obj.c.x, obj.a.y - obj.c.y, 0);
b.set(obj.b.x - obj.c.x, obj.b.y - obj.c.y, 0);
var dir = a.cross(b).z > 0 ? 0 : 1;
var r = obj.r.get();
- append('', [obj.a.x, obj.a.y, r, r, dir, 1, obj.b.x, obj.b.y]);
+ out.line('', [obj.a.x, obj.a.y, r, r, dir, 1, obj.b.x, obj.b.y]);
} else if (obj._class === T.CIRCLE) {
- append('', [obj.c.x, obj.c.y, obj.r.get()]);
+ out.line('', [obj.c.x, obj.c.y, obj.r.get()]);
} else if (obj._class === T.DIM || obj._class === T.HDIM || obj._class === T.VDIM) {
}
}
- append('');
+ out.line('');
}
}
bbox.inc(20)
- return TCAD.io._format(""
+ return TCAD.io._format(""
};
TCAD.IO.prototype.dxfExport = function () {