flo-mat 3.0.10 → 3.0.12
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/__tests__/jsog/check-jsog-eql-calc.spec.ts +81 -0
- package/__tests__/jsog/decode-jsog.ts +85 -0
- package/__tests__/jsog/get-mats1.ts +41 -0
- package/__tests__/{cp-node/fs → jsog}/mat-dummys.ts +51 -564
- package/__tests__/jsog/to-jsog-breath-first.ts +107 -0
- package/__tests__/jsog/to-jsog-depth-first.ts +55 -0
- package/browser/index.js +126 -84
- package/browser/index.min.js +1 -1
- package/node/add-n-prong.ts/join-spokes.js.map +1 -1
- package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -1
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/contact-point/contact-point.js.map +1 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/corner/get-interface-ccw.js.map +1 -1
- package/node/cp-node/cp-node-fs.d.ts +2 -1
- package/node/cp-node/cp-node-fs.js +1 -2
- package/node/cp-node/cp-node-fs.js.map +1 -1
- package/node/cp-node/fs/cp-node-comparator.d.ts +3 -0
- package/node/cp-node/fs/cp-node-comparator.js +6 -0
- package/node/cp-node/fs/cp-node-comparator.js.map +1 -0
- package/node/cp-node/fs/find-first.js.map +1 -1
- package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
- package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
- package/node/cp-node/fs/get-branch.js.map +1 -1
- package/node/cp-node/fs/get-children.js.map +1 -1
- package/node/cp-node/fs/get-first-exit.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-to-next.js.map +1 -1
- package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
- package/node/cp-node/fs/get-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-vertex-forward-children.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.d.ts +1 -1
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-one-prong.js.map +1 -1
- package/node/cp-node/fs/is-sharp.js.map +1 -1
- package/node/cp-node/fs/is-terminating.js.map +1 -1
- package/node/cp-node/fs/traverse-cp.js.map +1 -1
- package/node/cp-node/fs/traverse-edges.js.map +1 -1
- package/node/cp-node/fs/traverse-vertices.js.map +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.js +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-cull.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-speed.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-vertex.js.map +1 -1
- package/node/debug/functions/general.js.map +1 -1
- package/node/find-2-prong/add-1-prong.js.map +1 -1
- package/node/find-2-prong/find-2-prong.d.ts +1 -0
- package/node/find-2-prong/find-2-prong.js +2 -1
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -1
- package/node/find-3-prong.ts/find-3-prong.js.map +1 -1
- package/node/find-3-prong.ts/find-and-add-3-prong.js.map +1 -1
- package/node/find-3-prong.ts/find-and-add-3-prongs.js.map +1 -1
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/mat-options.js +1 -1
- package/node/find-mat/mat-options.js.map +1 -1
- package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/index.d.ts +35 -1
- package/node/index.js +36 -1
- package/node/index.js.map +1 -1
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/memoize-primitive.js.map +1 -1
- package/node/sat/add-debug-info.js.map +1 -1
- package/node/sat/get-leaves.js.map +1 -1
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-min-y-pos.js.map +1 -1
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/package.json +4 -4
- package/src/add-n-prong.ts/join-spokes.ts +11 -11
- package/src/closest-boundary-point/dd-deflate-with-running-error.ts +22 -22
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +38 -38
- package/src/contact-point/contact-point.ts +13 -13
- package/src/corner/get-corner.ts +39 -39
- package/src/corner/get-interface-ccw.ts +3 -3
- package/src/cp-node/cp-node-fs.ts +132 -135
- package/src/cp-node/cp-node.ts +30 -30
- package/src/cp-node/fs/clone.ts +4 -4
- package/src/cp-node/fs/cp-node-comparator.ts +13 -0
- package/src/cp-node/fs/find-first.ts +6 -6
- package/src/cp-node/fs/get-all-on-loop.ts +1 -1
- package/src/cp-node/fs/get-branch-beziers.ts +1 -1
- package/src/cp-node/fs/get-branch.ts +1 -1
- package/src/cp-node/fs/get-children.ts +8 -8
- package/src/cp-node/fs/get-first-exit.ts +11 -11
- package/src/cp-node/fs/get-mat-curve-to-next.ts +1 -1
- package/src/cp-node/fs/get-mat-curves-between.ts +1 -1
- package/src/cp-node/fs/get-prong-count.ts +8 -8
- package/src/cp-node/fs/get-real-prong-count.ts +3 -3
- package/src/cp-node/fs/get-vertex-forward-children.ts +10 -10
- package/src/cp-node/fs/is-fully-terminating.ts +3 -3
- package/src/cp-node/fs/is-one-prong.ts +8 -8
- package/src/cp-node/fs/is-sharp.ts +1 -1
- package/src/cp-node/fs/is-terminating.ts +1 -1
- package/src/cp-node/fs/iterate-all-on-loop.ts +6 -6
- package/src/cp-node/fs/traverse-all-forward.ts +11 -11
- package/src/cp-node/fs/traverse-cp.ts +19 -17
- package/src/cp-node/fs/traverse-edges.ts +10 -10
- package/src/cp-node/fs/traverse-vertices.ts +17 -17
- package/src/curve/curve.ts +26 -26
- package/src/debug/functions/cmp-cp-on-delta.ts +1 -1
- package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
- package/src/debug/functions/draw-elem/culls.ts +2 -2
- package/src/debug/functions/draw-elem/draw-cp-node.ts +30 -30
- package/src/debug/functions/draw-elem/draw-cull.ts +2 -2
- package/src/debug/functions/draw-elem/draw-dull-corner.ts +7 -7
- package/src/debug/functions/draw-elem/draw-elem.ts +28 -28
- package/src/debug/functions/draw-elem/draw-leaves.ts +12 -12
- package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +7 -7
- package/src/debug/functions/draw-elem/draw-max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/draw-min-y.ts +2 -2
- package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +1 -1
- package/src/debug/functions/draw-elem/draw-one-prong.ts +1 -1
- package/src/debug/functions/draw-elem/draw-sharp-corner.ts +6 -6
- package/src/debug/functions/draw-elem/draw-speed.ts +2 -2
- package/src/debug/functions/draw-elem/draw-three-prong.ts +28 -28
- package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +4 -4
- package/src/debug/functions/draw-elem/draw-two-prong.ts +51 -51
- package/src/debug/functions/draw-elem/draw-vertex.ts +12 -12
- package/src/debug/functions/draw-elem/dull-corner.ts +7 -7
- package/src/debug/functions/draw-elem/leaves.ts +2 -2
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +7 -7
- package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/min-y.ts +2 -2
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +1 -1
- package/src/debug/functions/draw-elem/one-prong.ts +1 -1
- package/src/debug/functions/draw-elem/sharp-corner.ts +6 -6
- package/src/debug/functions/draw-elem/three-prong.ts +19 -19
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +4 -4
- package/src/debug/functions/draw-elem/two-prong.ts +34 -34
- package/src/debug/functions/draw-elem/vertex.ts +28 -28
- package/src/debug/functions/general.ts +18 -18
- package/src/debug/functions/three-prong.ts +184 -184
- package/src/debug/functions/two-prong.ts +112 -112
- package/src/find-2-prong/add-1-prong.ts +25 -25
- package/src/find-2-prong/find-2-prong.ts +158 -157
- package/src/find-2-prong/find-equidistant-point-on-line-dd.ts +50 -50
- package/src/find-2-prong/find-equidistant-point-on-line.ts +27 -27
- package/src/find-3-prong.ts/find-3-prong-for-delta3s.ts +1 -1
- package/src/find-3-prong.ts/find-3-prong.ts +23 -23
- package/src/find-3-prong.ts/find-and-add-3-prong.ts +37 -37
- package/src/find-3-prong.ts/find-and-add-3-prongs.ts +30 -30
- package/src/find-mat/add-2-prongs-by-error.ts +1 -1
- package/src/find-mat/find-mats.ts +49 -49
- package/src/find-mat/fix-ordering.ts +2 -2
- package/src/find-mat/get-total-by.ts +12 -12
- package/src/find-mat/mat-options.ts +1 -1
- package/src/geometry/get-closest-square-distance-to-rect.ts +37 -37
- package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +14 -14
- package/src/get-curve/get-curve-between.ts +1 -1
- package/src/index.ts +40 -3
- package/src/mat/cmp-cp-on-delta.ts +1 -1
- package/src/mat/create-new-cp-tree.ts +12 -12
- package/src/mat/get-edges-as-array.ts +9 -9
- package/src/mat/get-largest-3-prong.ts +8 -8
- package/src/mat/get-largest-three-prong.ts +5 -5
- package/src/mat/get-largest-vertex.ts +6 -6
- package/src/mat/get-two-prong-type.ts +3 -3
- package/src/mat/trim-mat.ts +1 -1
- package/src/memoize-primitive.ts +14 -14
- package/src/sat/add-debug-info.ts +4 -4
- package/src/sat/cull-by-salience.ts +1 -1
- package/src/sat/get-leaves.ts +0 -1
- package/src/svg/get-extreme.ts +8 -8
- package/src/svg/get-loop-bounds.ts +84 -84
- package/src/svg/get-min-y-pos.ts +1 -1
- package/src/sweep-line/sweep-line.ts +23 -23
- package/__tests__/cp-node/fs/check-jsog-eql-calc.spec.ts +0 -30
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
Copy/paste this into the Chrome console to serialize an object to JSOG
|
|
4
|
+
and copy the result to clipboard. Replace `temp1` with your root object.
|
|
5
|
+
*/
|
|
6
|
+
// (() => {
|
|
7
|
+
// const encoded = toJsogBreathFirst(temp1);
|
|
8
|
+
// copy(JSON.stringify(encoded, null, 2));
|
|
9
|
+
// })();
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function toJsogBreathFirst(v: any) {
|
|
13
|
+
const seen = new Map();
|
|
14
|
+
let nextId = 1;
|
|
15
|
+
|
|
16
|
+
type QueueItem =
|
|
17
|
+
| { kind: 'array'; source: any[]; target: any[] }
|
|
18
|
+
| { kind: 'map'; source: Map<any, any>; target: { '@id': string; '@type': 'Map'; entries: any[] } }
|
|
19
|
+
| { kind: 'set'; source: Set<any>; target: { '@id': string; '@type': 'Set'; values: any[] } }
|
|
20
|
+
| { kind: 'object'; source: Record<string, any>; target: Record<string, any> };
|
|
21
|
+
|
|
22
|
+
const queue: QueueItem[] = [];
|
|
23
|
+
|
|
24
|
+
function encodeValue(value: any): any {
|
|
25
|
+
if (value === null || typeof value !== 'object') return value;
|
|
26
|
+
|
|
27
|
+
if (seen.has(value)) {
|
|
28
|
+
return { '@ref': seen.get(value) };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Arrays are encoded by value only because JSON drops custom array props
|
|
32
|
+
// like "@id" during stringify.
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
const result: any[] = new Array(value.length);
|
|
35
|
+
queue.push({ kind: 'array', source: value, target: result });
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const id = String(nextId++);
|
|
40
|
+
seen.set(value, id);
|
|
41
|
+
|
|
42
|
+
if (value instanceof Map) {
|
|
43
|
+
const result = {
|
|
44
|
+
'@id': id,
|
|
45
|
+
'@type': 'Map' as const,
|
|
46
|
+
entries: [] as any[]
|
|
47
|
+
};
|
|
48
|
+
queue.push({ kind: 'map', source: value, target: result });
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (value instanceof Set) {
|
|
53
|
+
const result = {
|
|
54
|
+
'@id': id,
|
|
55
|
+
'@type': 'Set' as const,
|
|
56
|
+
values: [] as any[]
|
|
57
|
+
};
|
|
58
|
+
queue.push({ kind: 'set', source: value, target: result });
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const result: Record<string, any> = { '@id': id };
|
|
63
|
+
queue.push({ kind: 'object', source: value, target: result });
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const encoded = encodeValue(v);
|
|
68
|
+
|
|
69
|
+
while (queue.length > 0) {
|
|
70
|
+
const item = queue.shift()!;
|
|
71
|
+
|
|
72
|
+
if (item.kind === 'array') {
|
|
73
|
+
for (let i = 0; i < item.source.length; i++) {
|
|
74
|
+
item.target[i] = encodeValue(item.source[i]);
|
|
75
|
+
}
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (item.kind === 'map') {
|
|
80
|
+
for (const [k, val] of item.source.entries()) {
|
|
81
|
+
item.target.entries.push([encodeValue(k), encodeValue(val)]);
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (item.kind === 'set') {
|
|
87
|
+
for (const val of item.source.values()) {
|
|
88
|
+
item.target.values.push(encodeValue(val));
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const [key, val] of Object.entries(item.source)) {
|
|
94
|
+
item.target[key] = encodeValue(val);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// `copy` below is only available in the Chrome console.
|
|
99
|
+
// If you want to run this in Node.js, replace it with `console.log`.
|
|
100
|
+
// copy(JSON.stringify(encoded, null, 2));
|
|
101
|
+
// console.log(JSON.stringify(encoded, null, 2));
|
|
102
|
+
// console.log('JSOG copied to clipboard.');
|
|
103
|
+
return encoded;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
export { toJsogBreathFirst }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
function toJsogDepthFirst(v: any) {
|
|
3
|
+
const seen = new Map();
|
|
4
|
+
let nextId = 1;
|
|
5
|
+
|
|
6
|
+
function encode(obj: any): any {
|
|
7
|
+
if (obj === null || typeof obj !== 'object') return obj;
|
|
8
|
+
|
|
9
|
+
if (seen.has(obj)) {
|
|
10
|
+
return { '@ref': seen.get(obj) };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Arrays are encoded by value only because JSON drops custom array props
|
|
14
|
+
// like "@id" during stringify.
|
|
15
|
+
if (Array.isArray(obj)) {
|
|
16
|
+
return obj.map(encode);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const id = String(nextId++);
|
|
20
|
+
seen.set(obj, id);
|
|
21
|
+
|
|
22
|
+
if (obj instanceof Map) {
|
|
23
|
+
return {
|
|
24
|
+
'@id': id,
|
|
25
|
+
'@type': 'Map',
|
|
26
|
+
entries: [...obj.entries()].map(([k, v]) => [encode(k), encode(v)])
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (obj instanceof Set) {
|
|
31
|
+
return {
|
|
32
|
+
'@id': id,
|
|
33
|
+
'@type': 'Set',
|
|
34
|
+
values: [...obj.values()].map(value => encode(value))
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const result: Record<string, any> = { '@id': id };
|
|
39
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
40
|
+
result[key] = encode(value);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const encoded = encode(v);
|
|
46
|
+
|
|
47
|
+
// `copy` below is only available in the Chrome console.
|
|
48
|
+
// If you want to run this in Node.js, replace it with `console.log`.
|
|
49
|
+
// copy(JSON.stringify(encoded, null, 2));
|
|
50
|
+
console.log(JSON.stringify(encoded, null, 2));
|
|
51
|
+
// console.log('JSOG copied to clipboard.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
export { toJsogDepthFirst }
|
package/browser/index.js
CHANGED
|
@@ -892,48 +892,6 @@ function floydWarshall(graph) {
|
|
|
892
892
|
// INF INF INF 0
|
|
893
893
|
// floydWarshall(graph);//?
|
|
894
894
|
|
|
895
|
-
;// ./src/point-on-shape/compare-poss.ts
|
|
896
|
-
/**
|
|
897
|
-
* Compares two `PointOnShape`s according to their cyclic ordering imposed
|
|
898
|
-
* by their relative positions on the shape boundary.
|
|
899
|
-
* @param a The first `PointOnShape`.
|
|
900
|
-
* @param b The second `PointOnShape`.
|
|
901
|
-
* @internal
|
|
902
|
-
*/
|
|
903
|
-
function comparePoss(a, b) {
|
|
904
|
-
let res;
|
|
905
|
-
res = a.curve.idx - b.curve.idx;
|
|
906
|
-
if (res !== 0) {
|
|
907
|
-
return res;
|
|
908
|
-
}
|
|
909
|
-
res = a.t - b.t;
|
|
910
|
-
return res;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
;// ./src/contact-point/contact-point.ts
|
|
915
|
-
|
|
916
|
-
/**
|
|
917
|
-
* Primarily for internal use.
|
|
918
|
-
*
|
|
919
|
-
* Compares the two contact points according to their order along the shape
|
|
920
|
-
* boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
|
|
921
|
-
* @param a The first contact point.
|
|
922
|
-
* @param b The second contact point.
|
|
923
|
-
*/
|
|
924
|
-
function compareCps(a, b) {
|
|
925
|
-
let res = comparePoss(a.pointOnShape, b.pointOnShape);
|
|
926
|
-
if (res !== 0) {
|
|
927
|
-
return res;
|
|
928
|
-
}
|
|
929
|
-
res = a.order - b.order;
|
|
930
|
-
if (res !== 0) {
|
|
931
|
-
return res;
|
|
932
|
-
}
|
|
933
|
-
return a.order2 - b.order2;
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
895
|
;// ./src/cp-node/fs/get-all-on-loop.ts
|
|
938
896
|
function getAllOnLoop(cpNode) {
|
|
939
897
|
const cpStart = cpNode;
|
|
@@ -7174,6 +7132,55 @@ function getAllVertices(cpNode) {
|
|
|
7174
7132
|
}
|
|
7175
7133
|
|
|
7176
7134
|
|
|
7135
|
+
;// ./src/point-on-shape/compare-poss.ts
|
|
7136
|
+
/**
|
|
7137
|
+
* Compares two `PointOnShape`s according to their cyclic ordering imposed
|
|
7138
|
+
* by their relative positions on the shape boundary.
|
|
7139
|
+
* @param a The first `PointOnShape`.
|
|
7140
|
+
* @param b The second `PointOnShape`.
|
|
7141
|
+
* @internal
|
|
7142
|
+
*/
|
|
7143
|
+
function comparePoss(a, b) {
|
|
7144
|
+
let res;
|
|
7145
|
+
res = a.curve.idx - b.curve.idx;
|
|
7146
|
+
if (res !== 0) {
|
|
7147
|
+
return res;
|
|
7148
|
+
}
|
|
7149
|
+
res = a.t - b.t;
|
|
7150
|
+
return res;
|
|
7151
|
+
}
|
|
7152
|
+
|
|
7153
|
+
|
|
7154
|
+
;// ./src/contact-point/contact-point.ts
|
|
7155
|
+
|
|
7156
|
+
/**
|
|
7157
|
+
* Primarily for internal use.
|
|
7158
|
+
*
|
|
7159
|
+
* Compares the two contact points according to their order along the shape
|
|
7160
|
+
* boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
|
|
7161
|
+
* @param a The first contact point.
|
|
7162
|
+
* @param b The second contact point.
|
|
7163
|
+
*/
|
|
7164
|
+
function compareCps(a, b) {
|
|
7165
|
+
let res = comparePoss(a.pointOnShape, b.pointOnShape);
|
|
7166
|
+
if (res !== 0) {
|
|
7167
|
+
return res;
|
|
7168
|
+
}
|
|
7169
|
+
res = a.order - b.order;
|
|
7170
|
+
if (res !== 0) {
|
|
7171
|
+
return res;
|
|
7172
|
+
}
|
|
7173
|
+
return a.order2 - b.order2;
|
|
7174
|
+
}
|
|
7175
|
+
|
|
7176
|
+
|
|
7177
|
+
;// ./src/cp-node/fs/cp-node-comparator.ts
|
|
7178
|
+
|
|
7179
|
+
function cpNodeComparator(a, b) {
|
|
7180
|
+
return compareCps(a.cp, b.cp);
|
|
7181
|
+
}
|
|
7182
|
+
|
|
7183
|
+
|
|
7177
7184
|
;// ./src/cp-node/cp-node-fs.ts
|
|
7178
7185
|
|
|
7179
7186
|
|
|
@@ -7210,7 +7217,6 @@ function getAllVertices(cpNode) {
|
|
|
7210
7217
|
|
|
7211
7218
|
|
|
7212
7219
|
|
|
7213
|
-
const cpNodeComparator = (a, b) => compareCps(a.cp, b.cp);
|
|
7214
7220
|
const CpNodeFs = {
|
|
7215
7221
|
/**
|
|
7216
7222
|
* Returns the children of this `CpNode` when seen as a MAT edge. Only
|
|
@@ -7310,7 +7316,7 @@ const CpNodeFs = {
|
|
|
7310
7316
|
* Compares the order of two `CpNode`s. The order is cyclic and depends
|
|
7311
7317
|
* on a `CpNode`'s relative position along the shape boundary.
|
|
7312
7318
|
*/
|
|
7313
|
-
cpNodeComparator,
|
|
7319
|
+
cpNodeComparator: cpNodeComparator,
|
|
7314
7320
|
/**
|
|
7315
7321
|
* For debugging
|
|
7316
7322
|
* @param cpNode
|
|
@@ -8798,18 +8804,18 @@ const eval_de_casteljau_error_abs = Math.abs;
|
|
|
8798
8804
|
* ```
|
|
8799
8805
|
* // for cubic bezier curves
|
|
8800
8806
|
* return [
|
|
8801
|
-
*
|
|
8802
|
-
*
|
|
8807
|
+
* x_, // <E> === 3T + 9
|
|
8808
|
+
* y_ // <E> === 3T + 9
|
|
8803
8809
|
* ];
|
|
8804
8810
|
* // for quadratic bezier curves
|
|
8805
8811
|
* return [
|
|
8806
|
-
*
|
|
8807
|
-
*
|
|
8812
|
+
* x_, // <E> === 2T + 6
|
|
8813
|
+
* y_ // <E> === 2T + 6
|
|
8808
8814
|
* ];
|
|
8809
8815
|
* // for linear bezier curves (i.e. lines)
|
|
8810
8816
|
* return [
|
|
8811
|
-
*
|
|
8812
|
-
*
|
|
8817
|
+
* x_, // <E> === T + 3
|
|
8818
|
+
* y_ // <E> === T + 3
|
|
8813
8819
|
* ];
|
|
8814
8820
|
* ```
|
|
8815
8821
|
*
|
|
@@ -19215,44 +19221,44 @@ const to_power_basis_error_counters_abs = Math.abs;
|
|
|
19215
19221
|
* ```
|
|
19216
19222
|
* // for cubic bezier curves
|
|
19217
19223
|
* return [
|
|
19218
|
-
*
|
|
19219
|
-
*
|
|
19220
|
-
*
|
|
19221
|
-
*
|
|
19222
|
-
*
|
|
19223
|
-
*
|
|
19224
|
-
*
|
|
19225
|
-
*
|
|
19226
|
-
*
|
|
19227
|
-
*
|
|
19228
|
-
*
|
|
19229
|
-
*
|
|
19224
|
+
* [
|
|
19225
|
+
* x3, // <E> === 3
|
|
19226
|
+
* x2, // <E> === 3
|
|
19227
|
+
* x1, // <E> === 2
|
|
19228
|
+
* 0,
|
|
19229
|
+
* ],
|
|
19230
|
+
* [
|
|
19231
|
+
* y3, // <E> === 3
|
|
19232
|
+
* y2, // <E> === 3
|
|
19233
|
+
* y1, // <E> === 2
|
|
19234
|
+
* 0,
|
|
19235
|
+
* ]
|
|
19230
19236
|
* ]
|
|
19231
19237
|
*
|
|
19232
19238
|
* // for quadratic bezier curves
|
|
19233
19239
|
* return [
|
|
19234
|
-
*
|
|
19235
|
-
*
|
|
19236
|
-
*
|
|
19237
|
-
*
|
|
19238
|
-
*
|
|
19239
|
-
*
|
|
19240
|
-
*
|
|
19241
|
-
*
|
|
19242
|
-
*
|
|
19243
|
-
*
|
|
19240
|
+
* [
|
|
19241
|
+
* x2, // <E> === 2
|
|
19242
|
+
* x1, // <E> === 1
|
|
19243
|
+
* 0,
|
|
19244
|
+
* ],
|
|
19245
|
+
* [
|
|
19246
|
+
* y2, // <E> === 2
|
|
19247
|
+
* y1, // <E> === 1
|
|
19248
|
+
* 0,
|
|
19249
|
+
* ]
|
|
19244
19250
|
* ];
|
|
19245
19251
|
*
|
|
19246
19252
|
* // for linear bezier curves (i.e. lines)
|
|
19247
19253
|
* return [
|
|
19248
|
-
*
|
|
19249
|
-
*
|
|
19250
|
-
*
|
|
19251
|
-
*
|
|
19252
|
-
*
|
|
19253
|
-
*
|
|
19254
|
-
*
|
|
19255
|
-
*
|
|
19254
|
+
* [
|
|
19255
|
+
* x1_, // <E> === 1
|
|
19256
|
+
* x0_ // <E> === 0
|
|
19257
|
+
* ],
|
|
19258
|
+
* [
|
|
19259
|
+
* y1_, // <E> === 1
|
|
19260
|
+
* y0_ // <E> === 0
|
|
19261
|
+
* ]
|
|
19256
19262
|
* ];
|
|
19257
19263
|
* ```
|
|
19258
19264
|
*
|
|
@@ -25793,7 +25799,7 @@ const matOptionRanges = {
|
|
|
25793
25799
|
range: [1, Number.POSITIVE_INFINITY],
|
|
25794
25800
|
},
|
|
25795
25801
|
simplifyTolerance: {
|
|
25796
|
-
range: [2 ** -
|
|
25802
|
+
range: [2 ** -20, 2 ** 20],
|
|
25797
25803
|
scaleByMaxCoordinate: true
|
|
25798
25804
|
},
|
|
25799
25805
|
minBezLength: {
|
|
@@ -28119,6 +28125,7 @@ const { ceil: find_2_prong_ceil, log2: find_2_prong_log2, max: find_2_prong_max,
|
|
|
28119
28125
|
* centered at an interior point x which contains two boundary portions c and
|
|
28120
28126
|
* d of dΩ as in Fig. 19."
|
|
28121
28127
|
* In fact, we (and they) start by fixing one point on the boundary beforehand.
|
|
28128
|
+
*
|
|
28122
28129
|
* @param loops A shape represented by path loops
|
|
28123
28130
|
* @param maxCoordinate The extreme coordinate value of the shape
|
|
28124
28131
|
* @param squaredDiagonalLength The squared diagonal length of the shape
|
|
@@ -28202,7 +28209,7 @@ function find2Prong(meta, isHoleClosing, for1Prong, angle, y) {
|
|
|
28202
28209
|
return undefined;
|
|
28203
28210
|
}
|
|
28204
28211
|
}
|
|
28205
|
-
// Find the point on the line connecting y with x that is
|
|
28212
|
+
// Find the point on the line connecting y with x that is
|
|
28206
28213
|
// equidistant from y and z. This will be our next x.
|
|
28207
28214
|
const nextX = findEquidistantPointOnLineDd(x, y.p, z.p);
|
|
28208
28215
|
const error = find_2_prong_abs(find_2_prong_sqrt(xy) - find_2_prong_sqrt(xz));
|
|
@@ -30261,7 +30268,7 @@ function drawCpNode(g, cpNode, classes = 'blue thin2 nofill', delay = 0, scaleFa
|
|
|
30261
30268
|
}
|
|
30262
30269
|
const $cross = crossHair(g, c, 'orange thin10 nofill', 2 * scaleFactor, delay);
|
|
30263
30270
|
// if (r === 0) {
|
|
30264
|
-
//
|
|
30271
|
+
// const $cross = crossHair(g, circle.center, 'red thin2 nofill', 0.02*scaleFactor, delay);
|
|
30265
30272
|
// }
|
|
30266
30273
|
return [...$cps, ...$ls, ...$circle, ...$cross];
|
|
30267
30274
|
}
|
|
@@ -30724,6 +30731,41 @@ function holeCloserNext(pairs, holeCloser) {
|
|
|
30724
30731
|
|
|
30725
30732
|
|
|
30726
30733
|
|
|
30734
|
+
|
|
30735
|
+
|
|
30736
|
+
|
|
30737
|
+
|
|
30738
|
+
|
|
30739
|
+
|
|
30740
|
+
|
|
30741
|
+
|
|
30742
|
+
|
|
30743
|
+
|
|
30744
|
+
|
|
30745
|
+
|
|
30746
|
+
|
|
30747
|
+
|
|
30748
|
+
// CpNodeFs functions
|
|
30749
|
+
|
|
30750
|
+
|
|
30751
|
+
|
|
30752
|
+
|
|
30753
|
+
|
|
30754
|
+
|
|
30755
|
+
|
|
30756
|
+
|
|
30757
|
+
|
|
30758
|
+
|
|
30759
|
+
|
|
30760
|
+
|
|
30761
|
+
|
|
30762
|
+
|
|
30763
|
+
|
|
30764
|
+
|
|
30765
|
+
|
|
30766
|
+
|
|
30767
|
+
|
|
30768
|
+
|
|
30727
30769
|
|
|
30728
30770
|
|
|
30729
30771
|
|
|
@@ -30740,4 +30782,4 @@ function holeCloserNext(pairs, holeCloser) {
|
|
|
30740
30782
|
|
|
30741
30783
|
|
|
30742
30784
|
|
|
30743
|
-
export { CpNodeFs, beziersToSvgPathStr, connectHoleClosers, createInitialCpTree, createPos, debugElemNames, drawBeziersAsSinglePath, drawBranch, drawElemFs, drawElemFsDetailed, drawMat, emptyDebugElems, enableDebugForMat, find2Prong, findAndAdd2Prong, findAndAddHoleClosing2Prongs, findMats, floydWarshall, getBoundaryBeziersToNext, getBoundaryPieceBeziers, getBranches, getCloseBoundaryPointsCertified, getClosestSquareDistanceToRect, getFor2ProngsOnLoop, getGraph, getImpliedBoundaryBezierBetween, getPartialMeta, getPathsFromStr, getPointToCpNode, getPotentialClosestPointsOnCurveCertified, getSatCulls, get_shape_bounds_getShapeBounds as getShapeBounds, getSharpCornersOnLoop, isVertexSpecial, loopFromBeziers, simplifyMat, sweep_line_sweepLine as sweepLine, toScaleAxis, trimMat };
|
|
30785
|
+
export { CpNodeFs, beziersToSvgPathStr, clone, connectHoleClosers, cpNodeComparator, createInitialCpTree, createPos, debugElemNames, drawBeziersAsSinglePath, drawBranch, drawElemFs, drawElemFsDetailed, drawMat, emptyDebugElems, enableDebugForMat, enhanceCpNode, find2Prong, findAndAdd2Prong, findAndAddHoleClosing2Prongs, findMats, floydWarshall, getAllOnCircle, getAllOnLoop, getAllVertices, getBoundaryBezierPartsToNext, getBoundaryBeziersBetween, getBoundaryBeziersToNext, getBoundaryPieceBeziers, getBranch, getBranchBeziers, getBranches, getChildren, getCloseBoundaryPointsCertified, getClosestSquareDistanceToRect, getEdgeDirection, getFirstExit, getFor2ProngsOnLoop, getGraph, getHoleClosers, getImpliedBoundaryBezierBetween, getInitialDegAngleBetweenMatCurves, getMatCurveBetween, getMatCurveToNext, getMatCurvesBetween, getPartialMeta, getPathsFromStr, getPointToCpNode, getPotentialClosestPointsOnCurveCertified, getProngCount, getRealProngCount, getSalience, getSatCulls, get_shape_bounds_getShapeBounds as getShapeBounds, getSharpCornersOnLoop, getSmoothedSpeed$, getSpeed, getVertexForwardChildren, isFullyTerminating, isOnSameCircle, isOneProng, isSharp, isTerminating, isTwoProng, isVertexSpecial, loopFromBeziers, removeVertex, simplifyMat, sweep_line_sweepLine as sweepLine, toScaleAxis, traverseCp, traverseEdges, traverseVertices, trimMat };
|