add new fdm-driver slice rendering

This commit is contained in:
Stewart Allen 2020-06-09 10:51:19 -04:00
commit a6310c6fbc
6 changed files with 172 additions and 8 deletions

View file

@ -28,6 +28,7 @@
trimTo : trimTo,
expand2 : expand2,
expand : expand,
expand_lines: expand_lines,
union : union,
nest : nest,
diff : doDiff,
@ -407,6 +408,27 @@
return sum;
}
/**
* @param {Polygon[]} polys
* @param {number} distance offset
* @param {number} [z] defaults to 0
*/
function expand_lines(poly, distance, z) {
let fact = CONF.clipper,
clib = self.ClipperLib,
clip = clib.Clipper,
cpft = clib.PolyFillType,
cjnt = clib.JoinType,
cety = clib.EndType,
coff = new clib.ClipperOffset(),
ctre = new clib.PolyTree();
coff.AddPaths(poly.toClipper(), cjnt.jtMiter, cety.etOpenSquare);
coff.Execute(ctre, distance * fact);
return fromClipperTree(ctre, z, null, null, 0);
}
/**
* @param {Polygon[]} polys
* @param {number} distance offset