Fix offset() bug where it produced 3 points too many in roundings

This commit is contained in:
Adrian Mariano
2025-08-23 00:00:18 -04:00
parent 64bb095204
commit 9636a2d245

View File

@@ -1097,7 +1097,7 @@ function offset(
goodsegs[i][0]-goodpath[i])) goodsegs[i][0]-goodpath[i]))
assert(!outsidecorner[i] || vang!=0, // If outsidecorner[i] is true then vang>0 needed to give valid step count assert(!outsidecorner[i] || vang!=0, // If outsidecorner[i] is true then vang>0 needed to give valid step count
"\nOffset computation failed, probably because validity check mistakenly removed a valid segment. Increasing quality might fix this.") "\nOffset computation failed, probably because validity check mistakenly removed a valid segment. Increasing quality might fix this.")
1+floor(segs(r)*vang/360) 1+segs(r,vang)
], ],
// newcorners is a list where each entry is a list of the points that correspond to a single point in the sharpcorners // newcorners is a list where each entry is a list of the points that correspond to a single point in the sharpcorners
// list: newcorners[i] is the point list that replaces goodpath[i]. Without rounding or chamfering (or reversals), // list: newcorners[i] is the point list that replaces goodpath[i]. Without rounding or chamfering (or reversals),
@@ -1134,7 +1134,7 @@ function offset(
) )
arc(cp=goodpath[i], cw=cw, ccw=ccw, arc(cp=goodpath[i], cw=cw, ccw=ccw,
points=basepts, points=basepts,
n=steps[i]+3) n=steps[i])
], ],
pointcount = [for(entry=newcorners) len(entry)], pointcount = [for(entry=newcorners) len(entry)],
edges = flatten(newcorners), edges = flatten(newcorners),