geometrix 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -16
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -339,6 +339,7 @@ declare class Contour extends AContour {
|
|
|
339
339
|
debugPoints: Point[];
|
|
340
340
|
debugLines: Line[];
|
|
341
341
|
lastPoint: Point;
|
|
342
|
+
lastPoint2: Point;
|
|
342
343
|
imposedColor: string;
|
|
343
344
|
/**
|
|
344
345
|
* @param ix - the X absolute coordinate of the first point of the contour
|
|
@@ -363,11 +364,11 @@ declare class Contour extends AContour {
|
|
|
363
364
|
addSegStrokeAP(aa: number, al: number): this;
|
|
364
365
|
addSegStrokeR(rx: number, ry: number): this;
|
|
365
366
|
addSegStrokeRP(ra: number, rl: number): this;
|
|
366
|
-
addSegStrokeAifBig(ax: number, ay: number, minLength: number, secondNfirst: boolean): this;
|
|
367
367
|
addSegArc(iRadius: number, iLarge: boolean, iCcw: boolean): this;
|
|
368
368
|
addSegArc2(): this;
|
|
369
369
|
addSegArc3(iTangentAngle1: number, firstNlast: boolean): this;
|
|
370
370
|
addSeg2Arcs(ita1: number, ita2: number): this;
|
|
371
|
+
addSegStrokeAifBig(ax: number, ay: number, minLength: number, secondNfirst: boolean): this;
|
|
371
372
|
addCornerPointed(): this;
|
|
372
373
|
addCornerRounded(iRadius: number): this;
|
|
373
374
|
addCornerWidened(iRadius: number): this;
|
package/dist/index.js
CHANGED
|
@@ -1724,6 +1724,7 @@ var Contour = class _Contour extends AContour {
|
|
|
1724
1724
|
debugPoints;
|
|
1725
1725
|
debugLines;
|
|
1726
1726
|
lastPoint;
|
|
1727
|
+
lastPoint2;
|
|
1727
1728
|
imposedColor;
|
|
1728
1729
|
/**
|
|
1729
1730
|
* @param ix - the X absolute coordinate of the first point of the contour
|
|
@@ -1737,10 +1738,12 @@ var Contour = class _Contour extends AContour {
|
|
|
1737
1738
|
this.debugPoints = [];
|
|
1738
1739
|
this.debugLines = [];
|
|
1739
1740
|
this.lastPoint = point(ix, iy);
|
|
1741
|
+
this.lastPoint2 = point(ix, iy);
|
|
1740
1742
|
this.imposedColor = icolor;
|
|
1741
1743
|
}
|
|
1742
1744
|
/** @internal */
|
|
1743
1745
|
setLastPoint(ix, iy) {
|
|
1746
|
+
this.lastPoint2 = this.lastPoint;
|
|
1744
1747
|
this.lastPoint = point(ix, iy);
|
|
1745
1748
|
}
|
|
1746
1749
|
/** @internal */
|
|
@@ -1813,22 +1816,6 @@ var Contour = class _Contour extends AContour {
|
|
|
1813
1816
|
this.addPointRP(ra, rl).addSegStroke();
|
|
1814
1817
|
return this;
|
|
1815
1818
|
}
|
|
1816
|
-
addSegStrokeAifBig(ax, ay, minLength, secondNfirst) {
|
|
1817
|
-
const p0 = this.getLastPoint();
|
|
1818
|
-
const ppLength = Math.sqrt((ax - p0.cx) ** 2 + (ay - p0.cy) ** 2);
|
|
1819
|
-
if (ppLength > minLength) {
|
|
1820
|
-
this.addPointA(ax, ay).addSegStroke();
|
|
1821
|
-
} else if (secondNfirst) {
|
|
1822
|
-
const preType = this.segments[this.segments.length - 1].sType;
|
|
1823
|
-
if (preType === 0 /* eStroke */) {
|
|
1824
|
-
this.segments.pop();
|
|
1825
|
-
this.addPointA(ax, ay).addSegStroke();
|
|
1826
|
-
} else {
|
|
1827
|
-
throw `err186: addSegStrokeA-ifBig used after a not eStroke ${preType} at segment ${this.segments.length}`;
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
return this;
|
|
1831
|
-
}
|
|
1832
1819
|
addSegArc(iRadius, iLarge, iCcw) {
|
|
1833
1820
|
if (this.points.length !== 1) {
|
|
1834
1821
|
throw `err954: contour addSegArc with unexpected points.length ${this.points.length}`;
|
|
@@ -1975,6 +1962,27 @@ var Contour = class _Contour extends AContour {
|
|
|
1975
1962
|
}
|
|
1976
1963
|
return this;
|
|
1977
1964
|
}
|
|
1965
|
+
addSegStrokeAifBig(ax, ay, minLength, secondNfirst) {
|
|
1966
|
+
const p0 = this.getLastPoint();
|
|
1967
|
+
const ppLength = Math.sqrt((ax - p0.cx) ** 2 + (ay - p0.cy) ** 2);
|
|
1968
|
+
if (ppLength > minLength) {
|
|
1969
|
+
this.addPointA(ax, ay).addSegStroke();
|
|
1970
|
+
} else if (secondNfirst) {
|
|
1971
|
+
const preSeg = this.segments[this.segments.length - 1];
|
|
1972
|
+
const lastP = this.lastPoint2;
|
|
1973
|
+
this.setLastPoint(lastP.cx, lastP.cy);
|
|
1974
|
+
if (preSeg.sType === 0 /* eStroke */) {
|
|
1975
|
+
this.segments.pop();
|
|
1976
|
+
this.addPointA(ax, ay).addSegStroke();
|
|
1977
|
+
} else if (preSeg.sType === 1 /* eArc */) {
|
|
1978
|
+
this.segments.pop();
|
|
1979
|
+
this.addPointA(ax, ay).addSegArc(preSeg.radius, preSeg.arcLarge, preSeg.arcCcw);
|
|
1980
|
+
} else {
|
|
1981
|
+
throw `err186: addSegStrokeA-ifBig used after eStart or eCorner ${preSeg.sType} at segment ${this.segments.length}`;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
return this;
|
|
1985
|
+
}
|
|
1978
1986
|
addCornerPointed() {
|
|
1979
1987
|
const seg = new Segment1(2 /* ePointed */, 0, 0, 0);
|
|
1980
1988
|
this.addSeg(seg);
|