@flighthq/path-boolean 0.5.1-next.3302.76ece6b → 0.5.1-next.4304.322dc96
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/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/booleanPaths.d.ts +33 -6
- package/dist/booleanPaths.d.ts.map +1 -1
- package/dist/booleanPaths.js +42 -3
- package/dist/booleanPaths.js.map +1 -1
- package/dist/contract.d.ts +12 -8
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +11 -8
- package/dist/contract.js.map +1 -1
- package/dist/contract.path-boolean-types.d.ts +4 -0
- package/dist/contract.path-boolean-types.d.ts.map +1 -0
- package/dist/contract.path-boolean-types.js +2 -0
- package/dist/contract.path-boolean-types.js.map +1 -0
- package/dist/explainPathBoolean.d.ts +15 -3
- package/dist/explainPathBoolean.d.ts.map +1 -1
- package/dist/explainPathBoolean.js +35 -9
- package/dist/explainPathBoolean.js.map +1 -1
- package/dist/index.d.ts +3 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -1
- package/dist/martinezKernel.d.ts +44 -4
- package/dist/martinezKernel.d.ts.map +1 -1
- package/dist/martinezKernel.js +777 -559
- package/dist/martinezKernel.js.map +1 -1
- package/dist/offsetPath.d.ts +15 -2
- package/dist/offsetPath.d.ts.map +1 -1
- package/dist/offsetPath.js +205 -215
- package/dist/offsetPath.js.map +1 -1
- package/dist/pathBoolean.d.ts +53 -0
- package/dist/pathBoolean.d.ts.map +1 -0
- package/dist/pathBoolean.js +115 -0
- package/dist/pathBoolean.js.map +1 -0
- package/dist/pathBooleanCompat.d.ts +3 -0
- package/dist/pathBooleanCompat.d.ts.map +1 -0
- package/dist/pathBooleanCompat.js +2 -0
- package/dist/pathBooleanCompat.js.map +1 -0
- package/dist/resolvePathRegions.d.ts +8 -2
- package/dist/resolvePathRegions.d.ts.map +1 -1
- package/dist/resolvePathRegions.js +11 -3
- package/dist/resolvePathRegions.js.map +1 -1
- package/dist/simplifyPath.d.ts +9 -2
- package/dist/simplifyPath.d.ts.map +1 -1
- package/dist/simplifyPath.js +12 -2
- package/dist/simplifyPath.js.map +1 -1
- package/dist/unionAllPaths.d.ts +9 -2
- package/dist/unionAllPaths.d.ts.map +1 -1
- package/dist/unionAllPaths.js +23 -8
- package/dist/unionAllPaths.js.map +1 -1
- package/dist/writePathBooleanContours.d.ts +8 -2
- package/dist/writePathBooleanContours.d.ts.map +1 -1
- package/dist/writePathBooleanContours.js +16 -4
- package/dist/writePathBooleanContours.js.map +1 -1
- package/package.json +5 -4
- package/src/booleanPaths.test.ts +237 -114
- package/src/explainPathBoolean.test.ts +35 -21
- package/src/fuzzInvariants.test.ts +241 -154
- package/src/martinezKernel.test.ts +334 -328
- package/src/offsetPath.test.ts +296 -166
- package/src/pathBoolean.test.ts +95 -0
- package/src/resolvePathRegions.test.ts +41 -30
- package/src/simplifyPath.test.ts +143 -112
- package/src/unionAllPaths.test.ts +93 -61
- package/src/writePathBooleanContours.test.ts +44 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathBoolean.d.ts","sourceRoot":"","sources":["../src/pathBoolean.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,yBAAyB,GAAG,aAAa,GAAG,kBAAkB,CAAC;AAE1G;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,+BAA+B,CAAC;IACpD,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,wCAAwC,CAAC,KAAK,EAAE,+BAA+B,GAAG,MAAM,CAUvG;AAED,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,4BAA4B,GAAG,MAAM,CAYjG;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAYnE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAcrE;AAED,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,MAAM,GAAG,+BAA+B,GAAG,SAAS,CAY/G;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAczG;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAc3E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAgB7E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Generated from crates/flight-path-boolean/src/path_boolean.rs by flight-compiler.
|
|
2
|
+
// Rust is authoritative; run `npm run generate` after changing it.
|
|
3
|
+
export function getPathBooleanExplanationOperationString(value) {
|
|
4
|
+
return (() => {
|
|
5
|
+
const matchValue = value;
|
|
6
|
+
switch (matchValue) {
|
|
7
|
+
case 'offset':
|
|
8
|
+
return 'offset';
|
|
9
|
+
case 'simplify':
|
|
10
|
+
return 'simplify';
|
|
11
|
+
}
|
|
12
|
+
})();
|
|
13
|
+
}
|
|
14
|
+
export function getPathBooleanExplanationReasonString(value) {
|
|
15
|
+
return (() => {
|
|
16
|
+
const matchValue = value;
|
|
17
|
+
switch (matchValue) {
|
|
18
|
+
case 'collapsed-or-degenerate':
|
|
19
|
+
return 'collapsed-or-degenerate';
|
|
20
|
+
case 'empty-input':
|
|
21
|
+
return 'empty-input';
|
|
22
|
+
case 'non-finite-delta':
|
|
23
|
+
return 'non-finite-delta';
|
|
24
|
+
}
|
|
25
|
+
})();
|
|
26
|
+
}
|
|
27
|
+
export function getPathOffsetEndString(value) {
|
|
28
|
+
return (() => {
|
|
29
|
+
const matchValue = value;
|
|
30
|
+
switch (matchValue) {
|
|
31
|
+
case 'butt':
|
|
32
|
+
return 'butt';
|
|
33
|
+
case 'round':
|
|
34
|
+
return 'round';
|
|
35
|
+
case 'square':
|
|
36
|
+
return 'square';
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
}
|
|
40
|
+
export function getPathOffsetJoinString(value) {
|
|
41
|
+
return (() => {
|
|
42
|
+
const matchValue = value;
|
|
43
|
+
switch (matchValue) {
|
|
44
|
+
case 'bevel':
|
|
45
|
+
return 'bevel';
|
|
46
|
+
case 'miter':
|
|
47
|
+
return 'miter';
|
|
48
|
+
case 'round':
|
|
49
|
+
return 'round';
|
|
50
|
+
case 'square':
|
|
51
|
+
return 'square';
|
|
52
|
+
}
|
|
53
|
+
})();
|
|
54
|
+
}
|
|
55
|
+
export function parsePathBooleanExplanationOperation(value) {
|
|
56
|
+
return (() => {
|
|
57
|
+
const matchValue = value;
|
|
58
|
+
switch (matchValue) {
|
|
59
|
+
case 'offset':
|
|
60
|
+
return 'offset';
|
|
61
|
+
case 'simplify':
|
|
62
|
+
return 'simplify';
|
|
63
|
+
default:
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
}
|
|
68
|
+
export function parsePathBooleanExplanationReason(value) {
|
|
69
|
+
return (() => {
|
|
70
|
+
const matchValue = value;
|
|
71
|
+
switch (matchValue) {
|
|
72
|
+
case 'collapsed-or-degenerate':
|
|
73
|
+
return 'collapsed-or-degenerate';
|
|
74
|
+
case 'empty-input':
|
|
75
|
+
return 'empty-input';
|
|
76
|
+
case 'non-finite-delta':
|
|
77
|
+
return 'non-finite-delta';
|
|
78
|
+
default:
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
}
|
|
83
|
+
export function parsePathOffsetEnd(value) {
|
|
84
|
+
return (() => {
|
|
85
|
+
const matchValue = value;
|
|
86
|
+
switch (matchValue) {
|
|
87
|
+
case 'butt':
|
|
88
|
+
return 'butt';
|
|
89
|
+
case 'round':
|
|
90
|
+
return 'round';
|
|
91
|
+
case 'square':
|
|
92
|
+
return 'square';
|
|
93
|
+
default:
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
})();
|
|
97
|
+
}
|
|
98
|
+
export function parsePathOffsetJoin(value) {
|
|
99
|
+
return (() => {
|
|
100
|
+
const matchValue = value;
|
|
101
|
+
switch (matchValue) {
|
|
102
|
+
case 'bevel':
|
|
103
|
+
return 'bevel';
|
|
104
|
+
case 'miter':
|
|
105
|
+
return 'miter';
|
|
106
|
+
case 'round':
|
|
107
|
+
return 'round';
|
|
108
|
+
case 'square':
|
|
109
|
+
return 'square';
|
|
110
|
+
default:
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=pathBoolean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathBoolean.js","sourceRoot":"","sources":["../src/pathBoolean.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,mEAAmE;AAsDnE,MAAM,UA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gBACV,OAAO,OAAO,CAAC;YACjB,KAAK,OAAO;gBACV,OAAO,OAAO,CAAC;YACjB,KAAK,QAAQ;gBACX,OAAO,QAAQ,CAAC;YAClB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathBooleanCompat.d.ts","sourceRoot":"","sources":["../src/pathBooleanCompat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAIhE,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathBooleanCompat.js","sourceRoot":"","sources":["../src/pathBooleanCompat.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Path } from '@flighthq/path/contract';
|
|
2
|
+
import type { PathBooleanFillRule, PathBooleanKernelRaw } from './martinezKernel.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a set of polygon contour rings under the given fill rule by self-unioning
|
|
5
|
+
* them through the boolean kernel. The result is a clean, hole-correct polygon outline
|
|
6
|
+
* written into `out`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolvePathRegions(out: Path, pathBooleanKernel: Readonly<PathBooleanKernelRaw>, rings: Readonly<number[][]>, fillRule: PathBooleanFillRule): void;
|
|
3
9
|
//# sourceMappingURL=resolvePathRegions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePathRegions.d.ts","sourceRoot":"","sources":["../src/resolvePathRegions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvePathRegions.d.ts","sourceRoot":"","sources":["../src/resolvePathRegions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGrF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,IAAI,EACT,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjD,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAC3B,QAAQ,EAAE,mBAAmB,GAC5B,IAAI,CASN"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
// Generated from crates/flight-path-boolean/src/resolve_path_regions.rs by flight-compiler.
|
|
2
|
+
// Rust is authoritative; run `npm run generate` after changing it.
|
|
1
3
|
import { writePathBooleanContours } from "./writePathBooleanContours.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a set of polygon contour rings under the given fill rule by self-unioning
|
|
6
|
+
* them through the boolean kernel. The result is a clean, hole-correct polygon outline
|
|
7
|
+
* written into `out`.
|
|
8
|
+
*/
|
|
2
9
|
export function resolvePathRegions(out, pathBooleanKernel, rings, fillRule) {
|
|
3
10
|
if (rings.length === 0) {
|
|
4
|
-
|
|
11
|
+
const empty = [];
|
|
12
|
+
writePathBooleanContours(out, empty);
|
|
5
13
|
return;
|
|
6
14
|
}
|
|
7
|
-
const
|
|
15
|
+
const empty = [];
|
|
16
|
+
const resolved = pathBooleanKernel.computePathBoolean(rings, empty, 'union', fillRule);
|
|
8
17
|
writePathBooleanContours(out, resolved);
|
|
9
18
|
}
|
|
10
|
-
const EMPTY_CONTOURS = [];
|
|
11
19
|
//# sourceMappingURL=resolvePathRegions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePathRegions.js","sourceRoot":"","sources":["../src/resolvePathRegions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvePathRegions.js","sourceRoot":"","sources":["../src/resolvePathRegions.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,mEAAmE;AAKnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAS,EACT,iBAAiD,EACjD,KAA2B,EAC3B,QAA6B;IAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,KAAK,GAAe,EAAa,CAAC;QACxC,wBAAwB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IACD,MAAM,KAAK,GAAe,EAAa,CAAC;IACxC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvF,wBAAwB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/simplifyPath.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Path } from '@flighthq/path/contract';
|
|
2
|
+
import type { PathBooleanKernelRaw } from './martinezKernel.ts';
|
|
3
|
+
import type { PathBooleanOptions } from './pathBoolean.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Flattens the input path to polygon contours and resolves self-overlaps under the
|
|
6
|
+
* given fill rule. The result is a clean, non-self-intersecting polygon outline. An
|
|
7
|
+
* empty or degenerate input produces an empty output path.
|
|
8
|
+
*/
|
|
9
|
+
export declare function simplifyPath(out: Path, pathBooleanKernel: Readonly<PathBooleanKernelRaw>, path: Readonly<Path>, options?: Readonly<PathBooleanOptions>): void;
|
|
3
10
|
//# sourceMappingURL=simplifyPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplifyPath.d.ts","sourceRoot":"","sources":["../src/simplifyPath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"simplifyPath.d.ts","sourceRoot":"","sources":["../src/simplifyPath.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAK3D;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,IAAI,EACT,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,EACpB,OAAO,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GACrC,IAAI,CAKN"}
|
package/dist/simplifyPath.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
// Generated from crates/flight-path-boolean/src/simplify_path.rs by flight-compiler.
|
|
2
|
+
// Rust is authoritative; run `npm run generate` after changing it.
|
|
1
3
|
import { flattenPath } from '@flighthq/path/contract';
|
|
4
|
+
import { getPathBooleanFillRuleForWinding } from "./booleanPaths.js";
|
|
2
5
|
import { resolvePathRegions } from "./resolvePathRegions.js";
|
|
6
|
+
const DEFAULT_FLATTEN_TOLERANCE = 0.25;
|
|
7
|
+
/**
|
|
8
|
+
* Flattens the input path to polygon contours and resolves self-overlaps under the
|
|
9
|
+
* given fill rule. The result is a clean, non-self-intersecting polygon outline. An
|
|
10
|
+
* empty or degenerate input produces an empty output path.
|
|
11
|
+
*/
|
|
3
12
|
export function simplifyPath(out, pathBooleanKernel, path, options) {
|
|
4
|
-
const fillRule = options?.fillRule ?? 'nonZero';
|
|
5
|
-
const
|
|
13
|
+
const fillRule = getPathBooleanFillRuleForWinding(options?.fillRule ?? 'nonZero');
|
|
14
|
+
const tolerance = options?.tolerance ?? DEFAULT_FLATTEN_TOLERANCE;
|
|
15
|
+
const contours = flattenPath(path, tolerance);
|
|
6
16
|
resolvePathRegions(out, pathBooleanKernel, contours, fillRule);
|
|
7
17
|
}
|
|
8
18
|
//# sourceMappingURL=simplifyPath.js.map
|
package/dist/simplifyPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplifyPath.js","sourceRoot":"","sources":["../src/simplifyPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,UAAU,YAAY,CAC1B,GAAS,EACT,
|
|
1
|
+
{"version":3,"file":"simplifyPath.js","sourceRoot":"","sources":["../src/simplifyPath.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,mEAAmE;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,yBAAyB,GAAW,IAAI,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAS,EACT,iBAAiD,EACjD,IAAoB,EACpB,OAAsC;IAEtC,MAAM,QAAQ,GAAG,gCAAgC,CAAC,OAAO,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC;IAClF,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,yBAAyB,CAAC;IAClE,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC9C,kBAAkB,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/unionAllPaths.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Path } from '@flighthq/path/contract';
|
|
2
|
+
import type { PathBooleanKernelRaw } from './martinezKernel.ts';
|
|
3
|
+
import type { PathBooleanOptions } from './pathBoolean.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Gathers every contour from every path in the list and unions them all together
|
|
6
|
+
* under the given fill rule. The result is a merged polygon outline written into
|
|
7
|
+
* `out`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function unionAllPaths(out: Path, pathBooleanKernel: Readonly<PathBooleanKernelRaw>, paths: Readonly<Readonly<Path>[]>, options?: Readonly<PathBooleanOptions>): void;
|
|
3
10
|
//# sourceMappingURL=unionAllPaths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unionAllPaths.d.ts","sourceRoot":"","sources":["../src/unionAllPaths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unionAllPaths.d.ts","sourceRoot":"","sources":["../src/unionAllPaths.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAK3D;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,IAAI,EACT,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjD,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACjC,OAAO,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GACrC,IAAI,CAkBN"}
|
package/dist/unionAllPaths.js
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
+
// Generated from crates/flight-path-boolean/src/union_all_paths.rs by flight-compiler.
|
|
2
|
+
// Rust is authoritative; run `npm run generate` after changing it.
|
|
1
3
|
import { flattenPath } from '@flighthq/path/contract';
|
|
4
|
+
import { getPathBooleanFillRuleForWinding } from "./booleanPaths.js";
|
|
2
5
|
import { writePathBooleanContours } from "./writePathBooleanContours.js";
|
|
6
|
+
const DEFAULT_FLATTEN_TOLERANCE = 0.25;
|
|
7
|
+
/**
|
|
8
|
+
* Gathers every contour from every path in the list and unions them all together
|
|
9
|
+
* under the given fill rule. The result is a merged polygon outline written into
|
|
10
|
+
* `out`.
|
|
11
|
+
*/
|
|
3
12
|
export function unionAllPaths(out, pathBooleanKernel, paths, options) {
|
|
4
|
-
const fillRule = options?.fillRule ?? 'nonZero';
|
|
5
|
-
const
|
|
13
|
+
const fillRule = getPathBooleanFillRuleForWinding(options?.fillRule ?? 'nonZero');
|
|
14
|
+
const tolerance = options?.tolerance ?? DEFAULT_FLATTEN_TOLERANCE;
|
|
15
|
+
let contours = [];
|
|
6
16
|
for (const path of paths) {
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
const pathContours = flattenPath(path, tolerance);
|
|
18
|
+
for (let index = 0, count = pathContours.length; index < count; index++) {
|
|
19
|
+
contours.push(pathContours[index]);
|
|
20
|
+
}
|
|
9
21
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
if (contours.length === 0) {
|
|
23
|
+
const empty = [];
|
|
24
|
+
writePathBooleanContours(out, empty);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const empty = [];
|
|
28
|
+
const result = pathBooleanKernel.computePathBoolean(contours, empty, 'union', fillRule);
|
|
13
29
|
writePathBooleanContours(out, result);
|
|
14
30
|
}
|
|
15
|
-
const EMPTY_CONTOURS = [];
|
|
16
31
|
//# sourceMappingURL=unionAllPaths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unionAllPaths.js","sourceRoot":"","sources":["../src/unionAllPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,UAAU,aAAa,CAC3B,GAAS,EACT,
|
|
1
|
+
{"version":3,"file":"unionAllPaths.js","sourceRoot":"","sources":["../src/unionAllPaths.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,m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Path
|
|
2
|
-
|
|
1
|
+
import type { Path } from '@flighthq/path/contract';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a set of polygon contour rings (flat interleaved `[x, y, ...]` coordinate
|
|
4
|
+
* arrays) into a `Path` of MoveTo/LineTo/Close commands. Each ring with at least three
|
|
5
|
+
* vertices becomes one closed sub-path in the output. The output path's winding is
|
|
6
|
+
* always set to `NonZero`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function writePathBooleanContours(out: Path, contours: Readonly<number[][]>): void;
|
|
3
9
|
//# sourceMappingURL=writePathBooleanContours.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writePathBooleanContours.d.ts","sourceRoot":"","sources":["../src/writePathBooleanContours.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"writePathBooleanContours.d.ts","sourceRoot":"","sources":["../src/writePathBooleanContours.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,IAAI,CAgBxF"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
// Generated from crates/flight-path-boolean/src/write_path_boolean_contours.rs by flight-compiler.
|
|
2
|
+
// Rust is authoritative; run `npm run generate` after changing it.
|
|
1
3
|
import { appendPathClose, appendPathLineTo, appendPathMoveTo } from '@flighthq/path/contract';
|
|
4
|
+
/**
|
|
5
|
+
* Converts a set of polygon contour rings (flat interleaved `[x, y, ...]` coordinate
|
|
6
|
+
* arrays) into a `Path` of MoveTo/LineTo/Close commands. Each ring with at least three
|
|
7
|
+
* vertices becomes one closed sub-path in the output. The output path's winding is
|
|
8
|
+
* always set to `NonZero`.
|
|
9
|
+
*/
|
|
2
10
|
export function writePathBooleanContours(out, contours) {
|
|
3
|
-
out.commands
|
|
4
|
-
out.data
|
|
11
|
+
out.commands = [];
|
|
12
|
+
out.data = [];
|
|
5
13
|
out.winding = 'nonZero';
|
|
6
14
|
for (const ring of contours) {
|
|
7
|
-
if (ring.length < 6)
|
|
15
|
+
if (ring.length < 6) {
|
|
8
16
|
continue;
|
|
17
|
+
}
|
|
9
18
|
appendPathMoveTo(out, ring[0], ring[1]);
|
|
10
|
-
|
|
19
|
+
let i = 2;
|
|
20
|
+
while (i < ring.length) {
|
|
11
21
|
appendPathLineTo(out, ring[i], ring[i + 1]);
|
|
22
|
+
i += 2;
|
|
23
|
+
}
|
|
12
24
|
appendPathClose(out);
|
|
13
25
|
}
|
|
14
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writePathBooleanContours.js","sourceRoot":"","sources":["../src/writePathBooleanContours.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG9F,MAAM,UAAU,wBAAwB,CAAC,GAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"writePathBooleanContours.js","sourceRoot":"","sources":["../src/writePathBooleanContours.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,mEAAmE;AAEnE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG9F;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAS,EAAE,QAA8B;IAChF,GAAG,CAAC,QAAQ,GAAG,EAAa,CAAC;IAC7B,GAAG,CAAC,IAAI,GAAG,EAAa,CAAC;IACzB,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC;IACxB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,SAAS;QACX,CAAC;QACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC5C,CAAC,IAAI,CAAC,CAAC;QACT,CAAC;QACD,eAAe,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/path-boolean",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.4304.322dc96",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,15 +32,16 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc -b",
|
|
34
34
|
"clean": "tsc -b --clean",
|
|
35
|
+
"generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-path-boolean --package path-boolean",
|
|
36
|
+
"generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-path-boolean --package path-boolean --check",
|
|
35
37
|
"test": "vitest run --config vitest.config.ts",
|
|
36
38
|
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
37
39
|
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
38
40
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/path": "0.5.1-next.
|
|
43
|
-
"@flighthq/types": "0.5.1-next.3302.76ece6b"
|
|
43
|
+
"@flighthq/entity": "0.5.1-next.4304.322dc96",
|
|
44
|
+
"@flighthq/path": "0.5.1-next.4304.322dc96"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"typescript": "^5.3.0"
|