@pooder/kit 5.3.0 → 5.3.1
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/CanvasService.js +249 -249
- package/.test-dist/src/ViewportSystem.js +75 -75
- package/.test-dist/src/background.js +203 -203
- package/.test-dist/src/bridgeSelection.js +20 -20
- package/.test-dist/src/constraints.js +237 -237
- package/.test-dist/src/dieline.js +818 -818
- package/.test-dist/src/edgeScale.js +12 -12
- package/.test-dist/src/feature.js +826 -826
- package/.test-dist/src/featureComplete.js +32 -32
- package/.test-dist/src/film.js +167 -167
- package/.test-dist/src/geometry.js +506 -506
- package/.test-dist/src/image.js +1250 -1250
- package/.test-dist/src/maskOps.js +270 -270
- package/.test-dist/src/mirror.js +104 -104
- package/.test-dist/src/renderSpec.js +2 -2
- package/.test-dist/src/ruler.js +343 -343
- package/.test-dist/src/sceneLayout.js +99 -99
- package/.test-dist/src/sceneLayoutModel.js +196 -196
- package/.test-dist/src/sceneView.js +40 -40
- package/.test-dist/src/sceneVisibility.js +42 -42
- package/.test-dist/src/size.js +332 -332
- package/.test-dist/src/tracer.js +544 -544
- package/.test-dist/src/white-ink.js +829 -829
- package/.test-dist/src/wrappedOffsets.js +33 -33
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +108 -20
- package/dist/index.mjs +108 -20
- package/package.json +1 -1
- package/src/coordinate.ts +106 -106
- package/src/extensions/background.ts +230 -230
- package/src/extensions/bridgeSelection.ts +17 -17
- package/src/extensions/constraints.ts +322 -322
- package/src/extensions/dieline.ts +46 -0
- package/src/extensions/edgeScale.ts +19 -19
- package/src/extensions/feature.ts +1021 -1021
- package/src/extensions/featureComplete.ts +46 -46
- package/src/extensions/film.ts +194 -194
- package/src/extensions/geometry.ts +752 -719
- package/src/extensions/image.ts +1926 -1924
- package/src/extensions/index.ts +11 -11
- package/src/extensions/maskOps.ts +283 -283
- package/src/extensions/mirror.ts +128 -128
- package/src/extensions/ruler.ts +451 -451
- package/src/extensions/sceneLayout.ts +140 -140
- package/src/extensions/sceneLayoutModel.ts +352 -342
- package/src/extensions/sceneVisibility.ts +71 -71
- package/src/extensions/size.ts +389 -389
- package/src/extensions/tracer.ts +58 -19
- package/src/extensions/white-ink.ts +1400 -1400
- package/src/extensions/wrappedOffsets.ts +33 -33
- package/src/index.ts +2 -2
- package/src/services/CanvasService.ts +300 -300
- package/src/services/ViewportSystem.ts +95 -95
- package/src/services/index.ts +3 -3
- package/src/services/renderSpec.ts +18 -18
- package/src/units.ts +27 -27
- package/tests/run.ts +118 -118
- package/tsconfig.test.json +15 -15
package/src/extensions/tracer.ts
CHANGED
|
@@ -306,14 +306,10 @@ export class ImageTracer {
|
|
|
306
306
|
|
|
307
307
|
const baseUnpaddedContours = baseContours
|
|
308
308
|
.map((contour) =>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
})),
|
|
314
|
-
width,
|
|
315
|
-
height,
|
|
316
|
-
),
|
|
309
|
+
contour.map((p) => ({
|
|
310
|
+
x: p.x - padding,
|
|
311
|
+
y: p.y - padding,
|
|
312
|
+
})),
|
|
317
313
|
)
|
|
318
314
|
.filter((contour) => contour.length > 2);
|
|
319
315
|
|
|
@@ -418,6 +414,49 @@ export class ImageTracer {
|
|
|
418
414
|
);
|
|
419
415
|
}
|
|
420
416
|
|
|
417
|
+
if (expand > 0) {
|
|
418
|
+
const expectedExpandedBounds = {
|
|
419
|
+
x: baseBounds.x - expand,
|
|
420
|
+
y: baseBounds.y - expand,
|
|
421
|
+
width: baseBounds.width + expand * 2,
|
|
422
|
+
height: baseBounds.height + expand * 2,
|
|
423
|
+
};
|
|
424
|
+
if (
|
|
425
|
+
expectedExpandedBounds.width > 0 &&
|
|
426
|
+
expectedExpandedBounds.height > 0 &&
|
|
427
|
+
globalBounds.width > 0 &&
|
|
428
|
+
globalBounds.height > 0
|
|
429
|
+
) {
|
|
430
|
+
const shouldNormalizeExpandBounds =
|
|
431
|
+
Math.abs(globalBounds.x - expectedExpandedBounds.x) > 1 ||
|
|
432
|
+
Math.abs(globalBounds.y - expectedExpandedBounds.y) > 1 ||
|
|
433
|
+
Math.abs(globalBounds.width - expectedExpandedBounds.width) > 1 ||
|
|
434
|
+
Math.abs(globalBounds.height - expectedExpandedBounds.height) > 1;
|
|
435
|
+
if (shouldNormalizeExpandBounds) {
|
|
436
|
+
const beforeNormalize = globalBounds;
|
|
437
|
+
finalContours = this.translateContours(
|
|
438
|
+
this.scaleContours(
|
|
439
|
+
finalContours,
|
|
440
|
+
expectedExpandedBounds.width,
|
|
441
|
+
expectedExpandedBounds.height,
|
|
442
|
+
globalBounds,
|
|
443
|
+
),
|
|
444
|
+
expectedExpandedBounds.x,
|
|
445
|
+
expectedExpandedBounds.y,
|
|
446
|
+
);
|
|
447
|
+
globalBounds = this.boundsFromPoints(
|
|
448
|
+
this.flattenContours(finalContours),
|
|
449
|
+
);
|
|
450
|
+
debugLog("traceWithBounds:expand-normalized", {
|
|
451
|
+
expand,
|
|
452
|
+
expectedExpandedBounds,
|
|
453
|
+
beforeNormalize,
|
|
454
|
+
afterNormalize: globalBounds,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
421
460
|
// Simplify and Generate SVG
|
|
422
461
|
debugLog("traceWithBounds:contours", {
|
|
423
462
|
baseContourCount: baseContoursRaw.length,
|
|
@@ -892,17 +931,17 @@ export class ImageTracer {
|
|
|
892
931
|
);
|
|
893
932
|
}
|
|
894
933
|
|
|
895
|
-
private static
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
): Point[] {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
934
|
+
private static translateContours(
|
|
935
|
+
contours: Point[][],
|
|
936
|
+
offsetX: number,
|
|
937
|
+
offsetY: number,
|
|
938
|
+
): Point[][] {
|
|
939
|
+
return contours.map((points) =>
|
|
940
|
+
points.map((p) => ({
|
|
941
|
+
x: p.x + offsetX,
|
|
942
|
+
y: p.y + offsetY,
|
|
943
|
+
})),
|
|
944
|
+
);
|
|
906
945
|
}
|
|
907
946
|
|
|
908
947
|
private static pointsToSVG(points: Point[]): string {
|