@pooder/kit 5.3.1 → 6.0.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.
- package/.test-dist/src/extensions/background.js +475 -131
- package/.test-dist/src/extensions/dieline.js +283 -180
- package/.test-dist/src/extensions/dielineShape.js +66 -0
- package/.test-dist/src/extensions/feature.js +388 -303
- package/.test-dist/src/extensions/film.js +133 -74
- package/.test-dist/src/extensions/geometry.js +120 -56
- package/.test-dist/src/extensions/image.js +296 -212
- package/.test-dist/src/extensions/index.js +1 -3
- package/.test-dist/src/extensions/maskOps.js +75 -20
- package/.test-dist/src/extensions/ruler.js +312 -215
- package/.test-dist/src/extensions/sceneLayoutModel.js +9 -3
- package/.test-dist/src/extensions/sceneVisibility.js +3 -10
- package/.test-dist/src/extensions/tracer.js +229 -58
- package/.test-dist/src/extensions/white-ink.js +139 -129
- package/.test-dist/src/services/CanvasService.js +888 -126
- package/.test-dist/src/services/index.js +1 -0
- package/.test-dist/src/services/visibility.js +54 -0
- package/.test-dist/tests/run.js +58 -4
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +377 -82
- package/dist/index.d.ts +377 -82
- package/dist/index.js +3920 -2178
- package/dist/index.mjs +3992 -2247
- package/package.json +1 -1
- package/src/extensions/background.ts +631 -145
- package/src/extensions/dieline.ts +280 -187
- package/src/extensions/dielineShape.ts +109 -0
- package/src/extensions/feature.ts +485 -366
- package/src/extensions/film.ts +152 -76
- package/src/extensions/geometry.ts +203 -104
- package/src/extensions/image.ts +319 -238
- package/src/extensions/index.ts +0 -1
- package/src/extensions/ruler.ts +481 -268
- package/src/extensions/sceneLayoutModel.ts +18 -6
- package/src/extensions/white-ink.ts +157 -171
- package/src/services/CanvasService.ts +1126 -140
- package/src/services/index.ts +1 -0
- package/src/services/renderSpec.ts +69 -4
- package/src/services/visibility.ts +78 -0
- package/tests/run.ts +139 -4
- package/.test-dist/src/CanvasService.js +0 -249
- package/.test-dist/src/ViewportSystem.js +0 -75
- package/.test-dist/src/background.js +0 -203
- package/.test-dist/src/bridgeSelection.js +0 -20
- package/.test-dist/src/constraints.js +0 -237
- package/.test-dist/src/dieline.js +0 -818
- package/.test-dist/src/edgeScale.js +0 -12
- package/.test-dist/src/feature.js +0 -826
- package/.test-dist/src/featureComplete.js +0 -32
- package/.test-dist/src/film.js +0 -167
- package/.test-dist/src/geometry.js +0 -506
- package/.test-dist/src/image.js +0 -1250
- package/.test-dist/src/maskOps.js +0 -270
- package/.test-dist/src/mirror.js +0 -104
- package/.test-dist/src/renderSpec.js +0 -2
- package/.test-dist/src/ruler.js +0 -343
- package/.test-dist/src/sceneLayout.js +0 -99
- package/.test-dist/src/sceneLayoutModel.js +0 -196
- package/.test-dist/src/sceneView.js +0 -40
- package/.test-dist/src/sceneVisibility.js +0 -42
- package/.test-dist/src/size.js +0 -332
- package/.test-dist/src/tracer.js +0 -544
- package/.test-dist/src/white-ink.js +0 -829
- package/.test-dist/src/wrappedOffsets.js +0 -33
- package/src/extensions/sceneVisibility.ts +0 -71
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.SceneLayoutService = void 0;
|
|
18
18
|
__exportStar(require("./background"), exports);
|
|
19
19
|
__exportStar(require("./image"), exports);
|
|
20
20
|
__exportStar(require("./size"), exports);
|
|
@@ -26,5 +26,3 @@ __exportStar(require("./ruler"), exports);
|
|
|
26
26
|
__exportStar(require("./white-ink"), exports);
|
|
27
27
|
var sceneLayout_1 = require("./sceneLayout");
|
|
28
28
|
Object.defineProperty(exports, "SceneLayoutService", { enumerable: true, get: function () { return sceneLayout_1.SceneLayoutService; } });
|
|
29
|
-
var sceneVisibility_1 = require("./sceneVisibility");
|
|
30
|
-
Object.defineProperty(exports, "SceneVisibilityService", { enumerable: true, get: function () { return sceneVisibility_1.SceneVisibilityService; } });
|
|
@@ -69,16 +69,21 @@ function analyzeAlpha(imageData, alphaOpaqueCutoff) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
function circularMorphology(mask, width, height, radius, op) {
|
|
72
|
-
const
|
|
72
|
+
const r = Math.max(0, Math.floor(radius));
|
|
73
|
+
if (r <= 0) {
|
|
74
|
+
return mask.slice();
|
|
75
|
+
}
|
|
76
|
+
// Disk kernel dilation (Euclidean metric).
|
|
77
|
+
const dilateDisk = (m, radiusPx) => {
|
|
73
78
|
const horizontalDist = new Int32Array(width * height);
|
|
74
79
|
for (let y = 0; y < height; y++) {
|
|
75
|
-
let lastSolid = -
|
|
80
|
+
let lastSolid = -radiusPx * 2;
|
|
76
81
|
for (let x = 0; x < width; x++) {
|
|
77
82
|
if (m[y * width + x])
|
|
78
83
|
lastSolid = x;
|
|
79
84
|
horizontalDist[y * width + x] = x - lastSolid;
|
|
80
85
|
}
|
|
81
|
-
lastSolid = width +
|
|
86
|
+
lastSolid = width + radiusPx * 2;
|
|
82
87
|
for (let x = width - 1; x >= 0; x--) {
|
|
83
88
|
if (m[y * width + x])
|
|
84
89
|
lastSolid = x;
|
|
@@ -86,12 +91,12 @@ function circularMorphology(mask, width, height, radius, op) {
|
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
const result = new Uint8Array(width * height);
|
|
89
|
-
const r2 =
|
|
94
|
+
const r2 = radiusPx * radiusPx;
|
|
90
95
|
for (let x = 0; x < width; x++) {
|
|
91
96
|
for (let y = 0; y < height; y++) {
|
|
92
97
|
let found = false;
|
|
93
|
-
const minY = Math.max(0, y -
|
|
94
|
-
const maxY = Math.min(height - 1, y +
|
|
98
|
+
const minY = Math.max(0, y - radiusPx);
|
|
99
|
+
const maxY = Math.min(height - 1, y + radiusPx);
|
|
95
100
|
for (let dy = minY; dy <= maxY; dy++) {
|
|
96
101
|
const dY = dy - y;
|
|
97
102
|
const hDist = horizontalDist[dy * width + x];
|
|
@@ -106,25 +111,75 @@ function circularMorphology(mask, width, height, radius, op) {
|
|
|
106
111
|
}
|
|
107
112
|
return result;
|
|
108
113
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
for (let
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
// Diamond kernel erosion (L1 metric), implemented as radius iterations of
|
|
115
|
+
// 4-neighbor erosion. This is intentionally different from dilation kernel.
|
|
116
|
+
const erodeDiamond = (m, radiusPx) => {
|
|
117
|
+
if (radiusPx <= 0)
|
|
118
|
+
return m.slice();
|
|
119
|
+
let current = m;
|
|
120
|
+
for (let step = 0; step < radiusPx; step++) {
|
|
121
|
+
const next = new Uint8Array(width * height);
|
|
122
|
+
for (let y = 1; y < height - 1; y++) {
|
|
123
|
+
const row = y * width;
|
|
124
|
+
for (let x = 1; x < width - 1; x++) {
|
|
125
|
+
const idx = row + x;
|
|
126
|
+
if (current[idx] &&
|
|
127
|
+
current[idx - 1] &&
|
|
128
|
+
current[idx + 1] &&
|
|
129
|
+
current[idx - width] &&
|
|
130
|
+
current[idx + width]) {
|
|
131
|
+
next[idx] = 1;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
current = next;
|
|
136
|
+
}
|
|
137
|
+
return current;
|
|
138
|
+
};
|
|
139
|
+
// Restore thin bridges removed by erosion: if a removed pixel links two
|
|
140
|
+
// opposite neighbors in the source mask, bring it back.
|
|
141
|
+
const restoreBridgePixels = (source, eroded) => {
|
|
142
|
+
const restored = eroded.slice();
|
|
143
|
+
for (let y = 1; y < height - 1; y++) {
|
|
144
|
+
const row = y * width;
|
|
145
|
+
for (let x = 1; x < width - 1; x++) {
|
|
146
|
+
const idx = row + x;
|
|
147
|
+
if (!source[idx] || restored[idx])
|
|
148
|
+
continue;
|
|
149
|
+
const up = source[idx - width] === 1;
|
|
150
|
+
const down = source[idx + width] === 1;
|
|
151
|
+
const left = source[idx - 1] === 1;
|
|
152
|
+
const right = source[idx + 1] === 1;
|
|
153
|
+
const upLeft = source[idx - width - 1] === 1;
|
|
154
|
+
const upRight = source[idx - width + 1] === 1;
|
|
155
|
+
const downLeft = source[idx + width - 1] === 1;
|
|
156
|
+
const downRight = source[idx + width + 1] === 1;
|
|
157
|
+
const keepsBridge = (left && right) ||
|
|
158
|
+
(up && down) ||
|
|
159
|
+
(upLeft && downRight) ||
|
|
160
|
+
(upRight && downLeft);
|
|
161
|
+
if (keepsBridge) {
|
|
162
|
+
restored[idx] = 1;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return restored;
|
|
167
|
+
};
|
|
168
|
+
const erodePreservingBridges = (m, radiusPx) => {
|
|
169
|
+
const eroded = erodeDiamond(m, radiusPx);
|
|
170
|
+
return restoreBridgePixels(m, eroded);
|
|
118
171
|
};
|
|
119
172
|
switch (op) {
|
|
120
173
|
case "dilate":
|
|
121
|
-
return
|
|
174
|
+
return dilateDisk(mask, r);
|
|
122
175
|
case "erode":
|
|
123
|
-
return
|
|
124
|
-
case "closing":
|
|
125
|
-
|
|
176
|
+
return erodePreservingBridges(mask, r);
|
|
177
|
+
case "closing": {
|
|
178
|
+
const erodeRadius = Math.max(1, Math.floor(r * 0.65));
|
|
179
|
+
return erodePreservingBridges(dilateDisk(mask, r), erodeRadius);
|
|
180
|
+
}
|
|
126
181
|
case "opening":
|
|
127
|
-
return
|
|
182
|
+
return dilateDisk(erodePreservingBridges(mask, r), r);
|
|
128
183
|
default:
|
|
129
184
|
return mask;
|
|
130
185
|
}
|