@pooder/kit 5.3.1 → 5.4.0

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.
Files changed (90) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.d.mts +243 -36
  3. package/dist/index.d.ts +243 -36
  4. package/dist/index.js +2278 -1041
  5. package/dist/index.mjs +2278 -1041
  6. package/package.json +1 -1
  7. package/src/coordinate.ts +106 -106
  8. package/src/extensions/background.ts +323 -230
  9. package/src/extensions/bridgeSelection.ts +17 -17
  10. package/src/extensions/constraints.ts +322 -322
  11. package/src/extensions/dieline.ts +1149 -1076
  12. package/src/extensions/dielineShape.ts +109 -0
  13. package/src/extensions/edgeScale.ts +19 -19
  14. package/src/extensions/feature.ts +1137 -1021
  15. package/src/extensions/featureComplete.ts +46 -46
  16. package/src/extensions/film.ts +266 -194
  17. package/src/extensions/geometry.ts +885 -752
  18. package/src/extensions/image.ts +2054 -1926
  19. package/src/extensions/index.ts +11 -11
  20. package/src/extensions/maskOps.ts +283 -283
  21. package/src/extensions/mirror.ts +128 -128
  22. package/src/extensions/ruler.ts +654 -451
  23. package/src/extensions/sceneLayout.ts +140 -140
  24. package/src/extensions/sceneLayoutModel.ts +364 -352
  25. package/src/extensions/sceneVisibility.ts +64 -71
  26. package/src/extensions/size.ts +389 -389
  27. package/src/extensions/tracer.ts +1019 -1019
  28. package/src/extensions/white-ink.ts +1567 -1514
  29. package/src/extensions/wrappedOffsets.ts +33 -33
  30. package/src/index.ts +2 -2
  31. package/src/services/CanvasService.ts +832 -300
  32. package/src/services/ViewportSystem.ts +95 -95
  33. package/src/services/index.ts +3 -3
  34. package/src/services/renderSpec.ts +53 -18
  35. package/src/units.ts +27 -27
  36. package/tests/run.ts +118 -118
  37. package/tsconfig.test.json +15 -15
  38. package/.test-dist/src/CanvasService.js +0 -249
  39. package/.test-dist/src/ViewportSystem.js +0 -75
  40. package/.test-dist/src/background.js +0 -203
  41. package/.test-dist/src/bridgeSelection.js +0 -20
  42. package/.test-dist/src/constraints.js +0 -237
  43. package/.test-dist/src/coordinate.js +0 -74
  44. package/.test-dist/src/dieline.js +0 -818
  45. package/.test-dist/src/edgeScale.js +0 -12
  46. package/.test-dist/src/extensions/background.js +0 -203
  47. package/.test-dist/src/extensions/bridgeSelection.js +0 -20
  48. package/.test-dist/src/extensions/constraints.js +0 -237
  49. package/.test-dist/src/extensions/dieline.js +0 -828
  50. package/.test-dist/src/extensions/edgeScale.js +0 -12
  51. package/.test-dist/src/extensions/feature.js +0 -825
  52. package/.test-dist/src/extensions/featureComplete.js +0 -32
  53. package/.test-dist/src/extensions/film.js +0 -167
  54. package/.test-dist/src/extensions/geometry.js +0 -545
  55. package/.test-dist/src/extensions/image.js +0 -1529
  56. package/.test-dist/src/extensions/index.js +0 -30
  57. package/.test-dist/src/extensions/maskOps.js +0 -279
  58. package/.test-dist/src/extensions/mirror.js +0 -104
  59. package/.test-dist/src/extensions/ruler.js +0 -345
  60. package/.test-dist/src/extensions/sceneLayout.js +0 -96
  61. package/.test-dist/src/extensions/sceneLayoutModel.js +0 -196
  62. package/.test-dist/src/extensions/sceneVisibility.js +0 -62
  63. package/.test-dist/src/extensions/size.js +0 -331
  64. package/.test-dist/src/extensions/tracer.js +0 -538
  65. package/.test-dist/src/extensions/white-ink.js +0 -1190
  66. package/.test-dist/src/extensions/wrappedOffsets.js +0 -33
  67. package/.test-dist/src/feature.js +0 -826
  68. package/.test-dist/src/featureComplete.js +0 -32
  69. package/.test-dist/src/film.js +0 -167
  70. package/.test-dist/src/geometry.js +0 -506
  71. package/.test-dist/src/image.js +0 -1250
  72. package/.test-dist/src/index.js +0 -18
  73. package/.test-dist/src/maskOps.js +0 -270
  74. package/.test-dist/src/mirror.js +0 -104
  75. package/.test-dist/src/renderSpec.js +0 -2
  76. package/.test-dist/src/ruler.js +0 -343
  77. package/.test-dist/src/sceneLayout.js +0 -99
  78. package/.test-dist/src/sceneLayoutModel.js +0 -196
  79. package/.test-dist/src/sceneView.js +0 -40
  80. package/.test-dist/src/sceneVisibility.js +0 -42
  81. package/.test-dist/src/services/CanvasService.js +0 -249
  82. package/.test-dist/src/services/ViewportSystem.js +0 -76
  83. package/.test-dist/src/services/index.js +0 -24
  84. package/.test-dist/src/services/renderSpec.js +0 -2
  85. package/.test-dist/src/size.js +0 -332
  86. package/.test-dist/src/tracer.js +0 -544
  87. package/.test-dist/src/units.js +0 -30
  88. package/.test-dist/src/white-ink.js +0 -829
  89. package/.test-dist/src/wrappedOffsets.js +0 -33
  90. package/.test-dist/tests/run.js +0 -94
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrappedDistance = wrappedDistance;
4
- exports.sampleWrappedOffsets = sampleWrappedOffsets;
5
- function wrappedDistance(total, start, end) {
6
- if (!Number.isFinite(total) || total <= 0)
7
- return 0;
8
- if (!Number.isFinite(start) || !Number.isFinite(end))
9
- return 0;
10
- const s = ((start % total) + total) % total;
11
- const e = ((end % total) + total) % total;
12
- return e >= s ? e - s : total - s + e;
13
- }
14
- function sampleWrappedOffsets(total, start, end, count) {
15
- if (!Number.isFinite(total) || total <= 0)
16
- return [];
17
- if (!Number.isFinite(start) || !Number.isFinite(end))
18
- return [];
19
- const n = Math.max(0, Math.floor(count));
20
- if (n <= 0)
21
- return [];
22
- const dist = wrappedDistance(total, start, end);
23
- if (n === 1)
24
- return [((start % total) + total) % total];
25
- const step = dist / (n - 1);
26
- const offsets = [];
27
- for (let i = 0; i < n; i++) {
28
- const raw = start + step * i;
29
- const wrapped = ((raw % total) + total) % total;
30
- offsets.push(wrapped);
31
- }
32
- return offsets;
33
- }
@@ -1,94 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bridgeSelection_1 = require("../src/bridgeSelection");
4
- const wrappedOffsets_1 = require("../src/wrappedOffsets");
5
- const maskOps_1 = require("../src/maskOps");
6
- const edgeScale_1 = require("../src/edgeScale");
7
- function assert(condition, message) {
8
- if (!condition)
9
- throw new Error(message);
10
- }
11
- function testWrappedOffsets() {
12
- assert((0, wrappedOffsets_1.wrappedDistance)(100, 10, 30) === 20, "distance 10->30 should be 20");
13
- assert((0, wrappedOffsets_1.wrappedDistance)(100, 90, 10) === 20, "distance 90->10 should wrap to 20");
14
- const a = (0, wrappedOffsets_1.sampleWrappedOffsets)(100, 10, 30, 5);
15
- assert(JSON.stringify(a) === JSON.stringify([10, 15, 20, 25, 30]), `unexpected sample: ${JSON.stringify(a)}`);
16
- const b = (0, wrappedOffsets_1.sampleWrappedOffsets)(100, 90, 10, 3);
17
- assert(JSON.stringify(b) === JSON.stringify([90, 0, 10]), `unexpected wrap sample: ${JSON.stringify(b)}`);
18
- }
19
- function testBridgeSelection() {
20
- const idx = (0, bridgeSelection_1.pickExitIndex)([
21
- { insideAbove: true, insideBelow: true },
22
- { insideAbove: false, insideBelow: true },
23
- { insideAbove: false, insideBelow: false },
24
- ]);
25
- assert(idx === 1, `expected exit index 1, got ${idx}`);
26
- const none = (0, bridgeSelection_1.pickExitIndex)([{ insideAbove: true, insideBelow: true }]);
27
- assert(none === -1, `expected -1, got ${none}`);
28
- const score = (0, bridgeSelection_1.scoreOutsideAbove)([
29
- { outsideAbove: true },
30
- { outsideAbove: false },
31
- { outsideAbove: true },
32
- ]);
33
- assert(score === 2, `expected score 2, got ${score}`);
34
- }
35
- function testMaskOps() {
36
- const width = 50;
37
- const height = 50;
38
- const mask = new Uint8Array(width * height);
39
- mask[10 * width + 10] = 1;
40
- mask[10 * width + 20] = 1;
41
- const r = (0, maskOps_1.findMinimalConnectRadius)(mask, width, height, 20);
42
- const closed = (0, maskOps_1.circularMorphology)(mask, width, height, r, "closing");
43
- assert((0, maskOps_1.isMaskConnected8)(closed, width, height), `closed mask should be connected (r=${r})`);
44
- if (r > 0) {
45
- const closedPrev = (0, maskOps_1.circularMorphology)(mask, width, height, r - 1, "closing");
46
- assert(!(0, maskOps_1.isMaskConnected8)(closedPrev, width, height), `r should be minimal (r=${r})`);
47
- }
48
- const donut = new Uint8Array(9 * 9);
49
- for (let y = 1; y <= 7; y++) {
50
- for (let x = 1; x <= 7; x++)
51
- donut[y * 9 + x] = 1;
52
- }
53
- for (let y = 3; y <= 5; y++) {
54
- for (let x = 3; x <= 5; x++)
55
- donut[y * 9 + x] = 0;
56
- }
57
- const filled = (0, maskOps_1.fillHoles)(donut, 9, 9);
58
- assert(filled[4 * 9 + 4] === 1, "hole should be filled");
59
- const imgW = 2;
60
- const imgH = 1;
61
- const rgba = new Uint8ClampedArray([
62
- 255, 255, 255, 255, 10, 10, 10, 254,
63
- ]);
64
- const imageData = { width: imgW, height: imgH, data: rgba };
65
- const paddedWidth = imgW + 4;
66
- const paddedHeight = imgH + 4;
67
- const created = (0, maskOps_1.createMask)(imageData, {
68
- threshold: 10,
69
- padding: 2,
70
- paddedWidth,
71
- paddedHeight,
72
- maskMode: "auto",
73
- alphaOpaqueCutoff: 250,
74
- });
75
- assert(created[2 * paddedWidth + 2] === 0, "white pixel should be background");
76
- assert(created[2 * paddedWidth + 3] === 1, "non-white pixel should be foreground");
77
- }
78
- function testEdgeScale() {
79
- const currentMax = 100;
80
- const baseBounds = { width: 50, height: 20 };
81
- const expandedBounds = { width: 70, height: 40 };
82
- const { width, height, scale } = (0, edgeScale_1.computeDetectEdgeSize)(currentMax, baseBounds, expandedBounds);
83
- assert(scale === 2, `expected scale 2, got ${scale}`);
84
- assert(width === 140, `expected width 140, got ${width}`);
85
- assert(height === 80, `expected height 80, got ${height}`);
86
- }
87
- function main() {
88
- testWrappedOffsets();
89
- testBridgeSelection();
90
- testMaskOps();
91
- testEdgeScale();
92
- console.log("ok");
93
- }
94
- main();