geometrix 0.5.29 → 0.5.31
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 +23 -1
- package/dist/index.js +42 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -615,8 +615,30 @@ declare class Transform3d {
|
|
|
615
615
|
}
|
|
616
616
|
declare function transform3d(initM?: tT3dMatrix): Transform3d;
|
|
617
617
|
|
|
618
|
+
/**
|
|
619
|
+
* The rectangle-origin is bottom-left.
|
|
620
|
+
*/
|
|
618
621
|
declare function ctrRectangle(ox: number, oy: number, width: number, height: number, cornerRounded?: number): tContour;
|
|
622
|
+
/**
|
|
623
|
+
* The rectangle-origin is bottom-left.
|
|
624
|
+
*/
|
|
619
625
|
declare function ctrRectRot(ox: number, oy: number, width: number, height: number, angle: number, cornerRounded?: number): tContour;
|
|
626
|
+
/**
|
|
627
|
+
* The rectangle-origin is middle-left.
|
|
628
|
+
*/
|
|
629
|
+
declare function ctrRectRot2(ox: number, oy: number, width: number, height: number, angle: number, cornerRounded?: number): tContour;
|
|
630
|
+
/**
|
|
631
|
+
* The trapezoid-origin is bottom-left.
|
|
632
|
+
*/
|
|
633
|
+
declare function ctrTrapezoid(ox: number, oy: number, bottomWidth: number, topWidth: number, height: number, cornerRounded?: number): tContour;
|
|
634
|
+
/**
|
|
635
|
+
* The trapezoid-origin is middle-left.
|
|
636
|
+
*/
|
|
637
|
+
declare function ctrTrapezoidRot2(ox: number, oy: number, leftSide: number, rightSide: number, Hlength: number, angle: number, cornerRounded?: number): tContour;
|
|
638
|
+
/**
|
|
639
|
+
* The oblong-origin is middle-left.
|
|
640
|
+
*/
|
|
641
|
+
declare function ctrOblong(ox: number, oy: number, Vwidth: number, Hlength: number, angle: number): tContour;
|
|
620
642
|
|
|
621
643
|
/** For cli-app and ui-app */
|
|
622
644
|
type tDependencies = Record<string, string>;
|
|
@@ -631,4 +653,4 @@ declare function version_details(appPackage: tPackage): string[];
|
|
|
631
653
|
|
|
632
654
|
declare function checkImpPages(pages: tAllPageDef): [boolean, string];
|
|
633
655
|
|
|
634
|
-
export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Transform3d, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustInit, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, ctrRectRot, ctrRectangle, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tExtrude, type tFaces, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxSeg, type tPaxSegArc, type tPaxSegSt, type tPolar, type tPosiOrien, type tSimTime, type tSubDesign, type tSubInst, type tT3dMatrix, type tVec3, type tVec4, type tVolume, tolerance, transform3d, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi, zeroPDef };
|
|
656
|
+
export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Transform3d, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustInit, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, ctrOblong, ctrRectRot, ctrRectRot2, ctrRectangle, ctrTrapezoid, ctrTrapezoidRot2, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tExtrude, type tFaces, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxSeg, type tPaxSegArc, type tPaxSegSt, type tPolar, type tPosiOrien, type tSimTime, type tSubDesign, type tSubInst, type tT3dMatrix, type tVec3, type tVec4, type tVolume, tolerance, transform3d, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi, zeroPDef };
|
package/dist/index.js
CHANGED
|
@@ -100,7 +100,13 @@ function radius2canvas(iRadius, iAdjust) {
|
|
|
100
100
|
if (roundZero(iAdjust.scaleX - Math.abs(iAdjust.scaleY)) !== 0) {
|
|
101
101
|
throw `err683: iAdjust.scaleX and scaleY differ ${iAdjust.scaleX} ${iAdjust.scaleY}`;
|
|
102
102
|
}
|
|
103
|
+
if (iAdjust.scaleX < 0) {
|
|
104
|
+
throw `err684: iAdjust.scaleX ${iAdjust.scaleX} is negative`;
|
|
105
|
+
}
|
|
103
106
|
const rRadius = iRadius * iAdjust.scaleX;
|
|
107
|
+
if (rRadius < 0) {
|
|
108
|
+
throw `err685: rRadius for canvas ${rRadius} is negative`;
|
|
109
|
+
}
|
|
104
110
|
return rRadius;
|
|
105
111
|
}
|
|
106
112
|
function adjustZero() {
|
|
@@ -2334,6 +2340,9 @@ var ContourCircle = class _ContourCircle extends AContour {
|
|
|
2334
2340
|
this.py = iy;
|
|
2335
2341
|
this.radius = iRadius;
|
|
2336
2342
|
this.imposedColor = icolor;
|
|
2343
|
+
if (iRadius < 0) {
|
|
2344
|
+
throw `err432: iRadius ${iRadius} is negative at circle ix ${ix}, iy ${iy}`;
|
|
2345
|
+
}
|
|
2337
2346
|
}
|
|
2338
2347
|
/** @internal */
|
|
2339
2348
|
clone() {
|
|
@@ -4059,6 +4068,35 @@ function ctrRectRot(ox, oy, width, height, angle, cornerRounded = 0) {
|
|
|
4059
4068
|
const rCtr = ctrRectangle(ox, oy, width, height, cornerRounded).rotate(ox, oy, angle);
|
|
4060
4069
|
return rCtr;
|
|
4061
4070
|
}
|
|
4071
|
+
function ctrRectRot2(ox, oy, width, height, angle, cornerRounded = 0) {
|
|
4072
|
+
const dpx = height / 2 * Math.sin(angle);
|
|
4073
|
+
const dpy = -height / 2 * Math.cos(angle);
|
|
4074
|
+
const rCtr = ctrRectRot(ox + dpx, oy + dpy, width, height, angle, cornerRounded);
|
|
4075
|
+
return rCtr;
|
|
4076
|
+
}
|
|
4077
|
+
function ctrTrapezoid(ox, oy, bottomWidth, topWidth, height, cornerRounded = 0) {
|
|
4078
|
+
const dw2 = (topWidth - bottomWidth) / 2;
|
|
4079
|
+
const rCtr = contour(ox, oy).addCornerRounded(cornerRounded).addSegStrokeR(bottomWidth, 0).addCornerRounded(cornerRounded).addSegStrokeR(dw2, height).addCornerRounded(cornerRounded).addSegStrokeR(-topWidth, 0).addCornerRounded(cornerRounded).closeSegStroke();
|
|
4080
|
+
return rCtr;
|
|
4081
|
+
}
|
|
4082
|
+
function ctrTrapezoidRot2(ox, oy, leftSide, rightSide, Hlength, angle, cornerRounded = 0) {
|
|
4083
|
+
const dw2 = (rightSide - leftSide) / 2;
|
|
4084
|
+
const dpx = leftSide / 2 * Math.sin(angle);
|
|
4085
|
+
const dpy = leftSide / 2 * Math.cos(angle);
|
|
4086
|
+
const ctr1 = contour(ox, oy).addCornerRounded(cornerRounded).addSegStrokeR(0, -leftSide).addCornerRounded(cornerRounded).addSegStrokeR(-dw2, Hlength).addCornerRounded(cornerRounded).addSegStrokeR(0, rightSide).addCornerRounded(cornerRounded).closeSegStroke();
|
|
4087
|
+
const rCtr = ctr1.rotate(ox, oy, angle).translate(-dpx, dpy);
|
|
4088
|
+
return rCtr;
|
|
4089
|
+
}
|
|
4090
|
+
function ctrOblong(ox, oy, Vwidth, Hlength, angle) {
|
|
4091
|
+
if (Hlength < Vwidth) {
|
|
4092
|
+
throw `err821: Hlength ${Hlength} is too small compare to Vwidth ${Vwidth}`;
|
|
4093
|
+
}
|
|
4094
|
+
const dpy = Vwidth / 2;
|
|
4095
|
+
const dpx = Hlength - Vwidth;
|
|
4096
|
+
const ctr1 = contour(dpy + dpx, -dpy).addPointA(dpy + dpx, dpy).addSegArc(dpy, false, true).addSegStrokeA(dpy, dpy).addPointA(dpy, -dpy).addSegArc(dpy, false, true).closeSegStroke();
|
|
4097
|
+
const rCtr = ctr1.rotate(0, 0, angle).translate(ox, oy);
|
|
4098
|
+
return rCtr;
|
|
4099
|
+
}
|
|
4062
4100
|
|
|
4063
4101
|
// src/version_details.ts
|
|
4064
4102
|
function version_details(appPackage) {
|
|
@@ -4137,8 +4175,12 @@ export {
|
|
|
4137
4175
|
contourCircle,
|
|
4138
4176
|
copyLayers,
|
|
4139
4177
|
createParamFile,
|
|
4178
|
+
ctrOblong,
|
|
4140
4179
|
ctrRectRot,
|
|
4180
|
+
ctrRectRot2,
|
|
4141
4181
|
ctrRectangle,
|
|
4182
|
+
ctrTrapezoid,
|
|
4183
|
+
ctrTrapezoidRot2,
|
|
4142
4184
|
degToRad,
|
|
4143
4185
|
designParam,
|
|
4144
4186
|
dxfSegArc,
|