add custom debur for rendering
This commit is contained in:
parent
e9057eac98
commit
e5956bd4c9
2 changed files with 29 additions and 2 deletions
|
|
@ -230,10 +230,33 @@
|
|||
return Math.abs(diff);
|
||||
}
|
||||
|
||||
PRO.debur = function(dist) {
|
||||
if (this.len < 2) {
|
||||
return null;
|
||||
}
|
||||
const pa = this.points,
|
||||
pln = pa.length,
|
||||
open = this.open,
|
||||
newp = newPolygon(),
|
||||
min = dist || BASE.config.precision_merge;
|
||||
let lo;
|
||||
newp.push(lo = pa[0]);
|
||||
for (let i=1; i<pln; i++) {
|
||||
if (lo.distTo2D(pa[i]) >= min) {
|
||||
newp.push(lo = pa[i]);
|
||||
}
|
||||
}
|
||||
newp.open = open;
|
||||
newp.parent = this.parent;
|
||||
if (newp.length < 2) {
|
||||
return null;
|
||||
}
|
||||
return newp;
|
||||
};
|
||||
|
||||
PRO.miter = function(debug) {
|
||||
if (this.length < 3) return this;
|
||||
|
||||
// todo - to eliminate path sharps in renders
|
||||
const slo = [], pa = this.points, pln = pa.length, open = this.open;
|
||||
let last;
|
||||
for (let i=1; i<pln; i++) {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,11 @@
|
|||
|
||||
polys.forEach(poly => {
|
||||
const contour = [];
|
||||
poly = poly.clean().miter();
|
||||
poly = poly.debur();
|
||||
if (!poly) return;
|
||||
poly = poly.miter();
|
||||
// cleaning converts open to closed which is problematic
|
||||
// poly = poly.clean().miter();
|
||||
// if (poly.debug) {
|
||||
// const save = this.current;
|
||||
// this.setLayer('debug.acute', 0xff0000).addPoly(poly, {thin:true});
|
||||
|
|
|
|||
Loading…
Reference in a new issue