geometrix 0.5.53 → 0.5.55

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 CHANGED
@@ -29,11 +29,13 @@ declare function canvas2point(cx: number, cy: number, iAdjust: tCanvasAdjust): [
29
29
  declare function canvasTranslatePolar(cx: number, cy: number, ia: number, il: number): [number, number];
30
30
  declare function radius2canvas(iRadius: number, iAdjust: tCanvasAdjust): number;
31
31
  declare function adjustZero(): tCanvasAdjust;
32
+ declare function adjustCopy(iAdjust: tCanvasAdjust): tCanvasAdjust;
32
33
  declare function adjustInit(xMin: number, xMax: number, yMin: number, yMax: number, cWidth: number, cHeight: number): tCanvasAdjust;
33
34
  declare function adjustCenter(px: number, py: number, iAdjust: tCanvasAdjust): tCanvasAdjust;
34
35
  declare function adjustRect(p1x: number, p1y: number, p2x: number, p2y: number, cWidth: number, cHeight: number): tCanvasAdjust;
35
36
  declare function adjustScale(iFactor: number, iAdjust: tCanvasAdjust): tCanvasAdjust;
36
37
  declare function adjustTranslate(p1x: number, p1y: number, p2x: number, p2y: number, iAdjust: tCanvasAdjust): tCanvasAdjust;
38
+ declare function adjustMini(widthOrig: number, widthTarget: number, iAdjust: tCanvasAdjust): tCanvasAdjust;
37
39
 
38
40
  declare const tolerance: number;
39
41
  declare function degToRad(degrees: number): number;
@@ -638,8 +640,8 @@ type tT3dMatrix = [tVec4, tVec4, tVec4, tVec4];
638
640
  declare class Transform3d {
639
641
  mmat: tT3dMatrix;
640
642
  constructor(iMat: tT3dMatrix);
641
- addRotation(ax: number, ay: number, az: number): void;
642
- addTranslation(ax: number, ay: number, az: number): void;
643
+ addRotation(ax: number, ay: number, az: number): Transform3d;
644
+ addTranslation(ax: number, ay: number, az: number): Transform3d;
643
645
  getMatrix(): tT3dMatrix;
644
646
  getRotation(): tVec3;
645
647
  getTranslation(): tVec3;
@@ -685,4 +687,4 @@ declare function version_details(appPackage: tPackage): string[];
685
687
 
686
688
  declare function checkImpPages(pages: tAllPageDef): [boolean, string];
687
689
 
688
- 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, midArcPoint, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointCoord, 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 tFigures, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tOuterInner, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxFace, 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 };
690
+ 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, adjustCopy, adjustInit, adjustMini, 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, midArcPoint, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointCoord, 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 tFigures, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tOuterInner, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxFace, 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
@@ -87,6 +87,7 @@ var colors = {
87
87
  reference: "blue",
88
88
  mouse: "yellow"
89
89
  };
90
+ var c_margin = 0.05;
90
91
  function point2canvas(px, py, iAdjust) {
91
92
  const cx2 = iAdjust.shiftX + (px - iAdjust.xMin) * iAdjust.scaleX;
92
93
  const cy2 = iAdjust.shiftY + (py - iAdjust.yMin) * iAdjust.scaleY;
@@ -128,6 +129,19 @@ function adjustZero() {
128
129
  };
129
130
  return rAdjustZero;
130
131
  }
132
+ function adjustCopy(iAdjust) {
133
+ const rAdjustZero = {
134
+ init: iAdjust.init,
135
+ xMin: iAdjust.xMin,
136
+ yMin: iAdjust.yMin,
137
+ xyDiff: iAdjust.xyDiff,
138
+ shiftX: iAdjust.shiftX,
139
+ shiftY: iAdjust.shiftY,
140
+ scaleX: iAdjust.scaleX,
141
+ scaleY: iAdjust.scaleY
142
+ };
143
+ return rAdjustZero;
144
+ }
131
145
  function adjustInit(xMin, xMax, yMin, yMax, cWidth, cHeight) {
132
146
  const rAdjust = adjustZero();
133
147
  const xDiff = Math.max(xMax - xMin, 1);
@@ -144,14 +158,14 @@ function adjustInit(xMin, xMax, yMin, yMax, cWidth, cHeight) {
144
158
  rAdjust.xMin = xMin;
145
159
  rAdjust.yMin = yMin;
146
160
  rAdjust.xyDiff = xyDiff;
147
- rAdjust.shiftX = 0.05 * cWidth;
161
+ rAdjust.shiftX = c_margin * cWidth;
148
162
  rAdjust.scaleX = xyScale;
149
- rAdjust.shiftY = cHeight - 0.05 * cHeight;
163
+ rAdjust.shiftY = cHeight - c_margin * cHeight;
150
164
  rAdjust.scaleY = -1 * xyScale;
151
165
  return rAdjust;
152
166
  }
153
167
  function adjustCenter(px, py, iAdjust) {
154
- const rAdjust = structuredClone(iAdjust);
168
+ const rAdjust = adjustCopy(iAdjust);
155
169
  rAdjust.xMin = px - rAdjust.xyDiff / 2;
156
170
  rAdjust.yMin = py - rAdjust.xyDiff / 2;
157
171
  return rAdjust;
@@ -165,7 +179,7 @@ function adjustRect(p1x, p1y, p2x, p2y, cWidth, cHeight) {
165
179
  return rAdjust;
166
180
  }
167
181
  function adjustScale(iFactor, iAdjust) {
168
- const rAdjust = structuredClone(iAdjust);
182
+ const rAdjust = adjustCopy(iAdjust);
169
183
  const shift = (1 - iFactor) / 2;
170
184
  rAdjust.xMin += shift * iAdjust.xyDiff;
171
185
  rAdjust.yMin += shift * iAdjust.xyDiff;
@@ -175,13 +189,25 @@ function adjustScale(iFactor, iAdjust) {
175
189
  return rAdjust;
176
190
  }
177
191
  function adjustTranslate(p1x, p1y, p2x, p2y, iAdjust) {
178
- const rAdjust = structuredClone(iAdjust);
192
+ const rAdjust = adjustCopy(iAdjust);
179
193
  const xDiff = p2x - p1x;
180
194
  const yDiff = p2y - p1y;
181
195
  rAdjust.xMin += -xDiff;
182
196
  rAdjust.yMin += -yDiff;
183
197
  return rAdjust;
184
198
  }
199
+ function adjustMini(widthOrig, widthTarget, iAdjust) {
200
+ const rAdjust = adjustCopy(iAdjust);
201
+ if (widthOrig > 0 && widthTarget > 0) {
202
+ const mf = widthOrig / widthTarget;
203
+ rAdjust.xyDiff *= mf;
204
+ rAdjust.scaleX *= 1 / mf;
205
+ rAdjust.scaleY *= 1 / mf;
206
+ rAdjust.shiftX += c_margin * widthTarget - c_margin * widthOrig;
207
+ rAdjust.shiftY += (1 - c_margin) * widthTarget - (1 - c_margin) * widthOrig;
208
+ }
209
+ return rAdjust;
210
+ }
185
211
 
186
212
  // src/triangle_utils.ts
187
213
  function rightTriLaFromLbLc(ilb, ilc) {
@@ -4526,10 +4552,12 @@ var Transform3d = class {
4526
4552
  addRotation(ax, ay, az) {
4527
4553
  const mR = t3dRotate(ax, ay, az);
4528
4554
  this.mmat = t3dCombine([this.mmat, mR]);
4555
+ return this;
4529
4556
  }
4530
4557
  addTranslation(ax, ay, az) {
4531
4558
  const mT = t3dTranslate(ax, ay, az);
4532
4559
  this.mmat = t3dCombine([this.mmat, mT]);
4560
+ return this;
4533
4561
  }
4534
4562
  getMatrix() {
4535
4563
  return this.mmat;
@@ -4650,7 +4678,9 @@ export {
4650
4678
  aCFromAaAb,
4651
4679
  aCFromLaLbLc,
4652
4680
  adjustCenter,
4681
+ adjustCopy,
4653
4682
  adjustInit,
4683
+ adjustMini,
4654
4684
  adjustRect,
4655
4685
  adjustScale,
4656
4686
  adjustTranslate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geometrix",
3
- "version": "0.5.53",
3
+ "version": "0.5.55",
4
4
  "description": "The 2D geometry engine of the parametrix",
5
5
  "private": false,
6
6
  "repository": {
@@ -63,21 +63,21 @@
63
63
  "clean": "rimraf dist node_modules"
64
64
  },
65
65
  "dependencies": {
66
- "@zip.js/zip.js": "^2.7.52",
66
+ "@zip.js/zip.js": "^2.7.53",
67
67
  "json5": "^2.2.3"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@eslint/js": "^9.10.0",
71
71
  "@types/eslint__js": "^8.42.3",
72
- "@types/node": "^22.7.8",
73
- "eslint": "^9.13.0",
72
+ "@types/node": "^22.9.0",
73
+ "eslint": "^9.14.0",
74
74
  "eslint-config-prettier": "^9.1.0",
75
- "npm-run-all2": "^7.0.0",
75
+ "npm-run-all2": "^7.0.1",
76
76
  "prettier": "^3.3.3",
77
77
  "rimraf": "^6.0.1",
78
- "tsup": "^8.3.0",
78
+ "tsup": "^8.3.5",
79
79
  "typescript": "^5.6.3",
80
- "typescript-eslint": "^8.11.0",
81
- "vitest": "^2.1.3"
80
+ "typescript-eslint": "^8.14.0",
81
+ "vitest": "^2.1.5"
82
82
  }
83
83
  }