make direction in/out configurable in code (needs ui help)

This commit is contained in:
Stewart Allen 2020-01-28 18:16:28 -05:00
commit b81c424241

View file

@ -760,26 +760,28 @@ var gs_kiri_print = exports;
} else { } else {
// top object // top object
var bounds = POLY.flatten(next.gatherOuter([])); var bounds = POLY.flatten(next.gatherOuter([]));
// outputTraces([].appendAll(next.traces).appendAll(next.innerTraces() || []), bounds);
// outside in let dir = -1; // 1 == inside out, -1 == outside-in
// output inner polygons
if (dir === 1)
outputTraces([].appendAll(next.innerTraces() || []), bounds);
// sort perimeter polygon by length to go out-to-in or in-to-out
(next.traces || []).sort(function(a,b) { (next.traces || []).sort(function(a,b) {
return a.perimeter() > b.perimeter() ? -1 : 1; return a.perimeter() > b.perimeter() ? dir : -dir;
}).forEach(function(poly, index) { }).forEach(function(poly, index) {
outputTraces(poly, bounds); outputTraces(poly, bounds);
}); });
// outputTraces([].appendAll(next.traces) || []), bounds); // outer first
// inside out // output inner polygons
// (next.innerTraces() || []).sort(function(a,b) { if (dir === -1)
// return a.perimeter() > b.perimeter() ? 1 : -1; outputTraces([].appendAll(next.innerTraces() || []), bounds);
// }).forEach(function(poly, index) {
// outputTraces(poly, bounds);
// });
outputTraces([].appendAll(next.innerTraces() || []), bounds); // inner last
// then output solid and sparse fill
outputFills(next.fill_lines, bounds); outputFills(next.fill_lines, bounds);
outputSparse(next.fill_sparse, bounds); outputSparse(next.fill_sparse, bounds);
lastTop = next; lastTop = next;
} }
}, function(obj) { }, function(obj) {