improve slice/preview visuals on open but really closed polys

This commit is contained in:
Stewart Allen 2022-10-14 23:09:18 -04:00
commit f5941befaf

View file

@ -301,17 +301,19 @@ function pointsToPath(points, offset, open, miter = 1.5) {
const p0 = points[0].normal; const p0 = points[0].normal;
const l0 = left[0]; const l0 = left[0];
const r0 = right[0]; const r0 = right[0];
l0.x += p0.dy * offset; // improve visuals of open but 90 degree overlapping ends
l0.y -= p0.dx * offset; const move = offset * 0.99;
r0.x += p0.dy * offset; l0.x += p0.dy * move;
r0.y -= p0.dx * offset; l0.y -= p0.dx * move;
r0.x += p0.dy * move;
r0.y -= p0.dx * move;
const pn = points.peek(2).normal; const pn = points.peek(2).normal;
const ln = left.peek(); const ln = left.peek();
const rn = right.peek(); const rn = right.peek();
ln.x -= pn.dy * offset; ln.x -= pn.dy * move;
ln.y += pn.dx * offset; ln.y += pn.dx * move;
rn.x -= pn.dy * offset; rn.x -= pn.dy * move;
rn.y += pn.dx * offset; rn.y += pn.dx * move;
} }
if (!open && faces) { if (!open && faces) {
let l1 = left.peek(1); let l1 = left.peek(1);