@pooder/kit 5.3.0 → 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 (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.mts +249 -36
  3. package/dist/index.d.ts +249 -36
  4. package/dist/index.js +2374 -1049
  5. package/dist/index.mjs +2375 -1050
  6. package/package.json +1 -1
  7. package/src/extensions/background.ts +178 -85
  8. package/src/extensions/dieline.ts +1149 -1030
  9. package/src/extensions/dielineShape.ts +109 -0
  10. package/src/extensions/feature.ts +482 -366
  11. package/src/extensions/film.ts +148 -76
  12. package/src/extensions/geometry.ts +210 -44
  13. package/src/extensions/image.ts +244 -114
  14. package/src/extensions/ruler.ts +471 -268
  15. package/src/extensions/sceneLayoutModel.ts +28 -6
  16. package/src/extensions/sceneVisibility.ts +3 -10
  17. package/src/extensions/tracer.ts +1019 -980
  18. package/src/extensions/white-ink.ts +284 -231
  19. package/src/services/CanvasService.ts +543 -11
  20. package/src/services/renderSpec.ts +37 -2
  21. package/.test-dist/src/CanvasService.js +0 -249
  22. package/.test-dist/src/ViewportSystem.js +0 -75
  23. package/.test-dist/src/background.js +0 -203
  24. package/.test-dist/src/bridgeSelection.js +0 -20
  25. package/.test-dist/src/constraints.js +0 -237
  26. package/.test-dist/src/coordinate.js +0 -74
  27. package/.test-dist/src/dieline.js +0 -818
  28. package/.test-dist/src/edgeScale.js +0 -12
  29. package/.test-dist/src/extensions/background.js +0 -203
  30. package/.test-dist/src/extensions/bridgeSelection.js +0 -20
  31. package/.test-dist/src/extensions/constraints.js +0 -237
  32. package/.test-dist/src/extensions/dieline.js +0 -828
  33. package/.test-dist/src/extensions/edgeScale.js +0 -12
  34. package/.test-dist/src/extensions/feature.js +0 -825
  35. package/.test-dist/src/extensions/featureComplete.js +0 -32
  36. package/.test-dist/src/extensions/film.js +0 -167
  37. package/.test-dist/src/extensions/geometry.js +0 -545
  38. package/.test-dist/src/extensions/image.js +0 -1529
  39. package/.test-dist/src/extensions/index.js +0 -30
  40. package/.test-dist/src/extensions/maskOps.js +0 -279
  41. package/.test-dist/src/extensions/mirror.js +0 -104
  42. package/.test-dist/src/extensions/ruler.js +0 -345
  43. package/.test-dist/src/extensions/sceneLayout.js +0 -96
  44. package/.test-dist/src/extensions/sceneLayoutModel.js +0 -196
  45. package/.test-dist/src/extensions/sceneVisibility.js +0 -62
  46. package/.test-dist/src/extensions/size.js +0 -331
  47. package/.test-dist/src/extensions/tracer.js +0 -538
  48. package/.test-dist/src/extensions/white-ink.js +0 -1190
  49. package/.test-dist/src/extensions/wrappedOffsets.js +0 -33
  50. package/.test-dist/src/feature.js +0 -826
  51. package/.test-dist/src/featureComplete.js +0 -32
  52. package/.test-dist/src/film.js +0 -167
  53. package/.test-dist/src/geometry.js +0 -506
  54. package/.test-dist/src/image.js +0 -1250
  55. package/.test-dist/src/index.js +0 -18
  56. package/.test-dist/src/maskOps.js +0 -270
  57. package/.test-dist/src/mirror.js +0 -104
  58. package/.test-dist/src/renderSpec.js +0 -2
  59. package/.test-dist/src/ruler.js +0 -343
  60. package/.test-dist/src/sceneLayout.js +0 -99
  61. package/.test-dist/src/sceneLayoutModel.js +0 -196
  62. package/.test-dist/src/sceneView.js +0 -40
  63. package/.test-dist/src/sceneVisibility.js +0 -42
  64. package/.test-dist/src/services/CanvasService.js +0 -249
  65. package/.test-dist/src/services/ViewportSystem.js +0 -76
  66. package/.test-dist/src/services/index.js +0 -24
  67. package/.test-dist/src/services/renderSpec.js +0 -2
  68. package/.test-dist/src/size.js +0 -332
  69. package/.test-dist/src/tracer.js +0 -544
  70. package/.test-dist/src/units.js +0 -30
  71. package/.test-dist/src/white-ink.js +0 -829
  72. package/.test-dist/src/wrappedOffsets.js +0 -33
  73. 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();