flo-mat 4.0.2 → 4.0.3

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 (101) hide show
  1. package/__tests__/specific-cases/specific-cases.spec.ts +6 -0
  2. package/browser/index.js +4511 -7115
  3. package/browser/index.min.js +1 -1
  4. package/node/cp-node/fs/is-on-same-loop.d.ts +3 -0
  5. package/node/cp-node/fs/is-on-same-loop.js +6 -0
  6. package/node/cp-node/fs/is-on-same-loop.js.map +1 -0
  7. package/node/debug/debug.d.ts +10 -15
  8. package/node/debug/debug.js +35 -46
  9. package/node/debug/debug.js.map +1 -1
  10. package/node/find-2-prong/add-1-prong.js +1 -4
  11. package/node/find-2-prong/add-1-prong.js.map +1 -1
  12. package/node/find-mat/find-mat.js +1 -2
  13. package/node/find-mat/find-mat.js.map +1 -1
  14. package/node/find-mat/get-meta.d.ts +1 -6
  15. package/node/find-mat/get-meta.js +4 -26
  16. package/node/find-mat/get-meta.js.map +1 -1
  17. package/node/index.d.ts +4 -2
  18. package/node/index.js +3 -1
  19. package/node/index.js.map +1 -1
  20. package/node/reconstruct-from-mat/filter-zero-length.d.ts +10 -0
  21. package/node/reconstruct-from-mat/filter-zero-length.js +14 -0
  22. package/node/reconstruct-from-mat/filter-zero-length.js.map +1 -0
  23. package/node/reconstruct-from-mat/get-all-on-loop-by-loop.d.ts +7 -0
  24. package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js +38 -0
  25. package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js.map +1 -0
  26. package/node/reconstruct-from-mat/get-bezier-piece-length.d.ts +3 -0
  27. package/node/reconstruct-from-mat/get-bezier-piece-length.js +6 -0
  28. package/node/reconstruct-from-mat/get-bezier-piece-length.js.map +1 -0
  29. package/node/reconstruct-from-mat/get-boundary.d.ts +7 -0
  30. package/node/reconstruct-from-mat/get-boundary.js +18 -0
  31. package/node/reconstruct-from-mat/get-boundary.js.map +1 -0
  32. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.d.ts +4 -0
  33. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js +15 -0
  34. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js.map +1 -0
  35. package/node/reconstruct-from-mat/get-matching-beziers.d.ts +10 -0
  36. package/node/reconstruct-from-mat/get-matching-beziers.js +29 -0
  37. package/node/reconstruct-from-mat/get-matching-beziers.js.map +1 -0
  38. package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.d.ts +6 -0
  39. package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js +10 -0
  40. package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js.map +1 -0
  41. package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.d.ts +7 -0
  42. package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js +47 -0
  43. package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js.map +1 -0
  44. package/node/reconstruct-from-mat/get-sats2.d.ts +10 -0
  45. package/node/reconstruct-from-mat/get-sats2.js +16 -0
  46. package/node/reconstruct-from-mat/get-sats2.js.map +1 -0
  47. package/node/reconstruct-from-mat/is-fully-terminating.d.ts +3 -0
  48. package/node/reconstruct-from-mat/is-fully-terminating.js +19 -0
  49. package/node/reconstruct-from-mat/is-fully-terminating.js.map +1 -0
  50. package/node/reconstruct-from-mat/matched-beziers.d.ts +10 -0
  51. package/node/reconstruct-from-mat/matched-beziers.js +2 -0
  52. package/node/reconstruct-from-mat/matched-beziers.js.map +1 -0
  53. package/node/reconstruct-from-mat/reconstruct-from-mat.d.ts +4 -0
  54. package/node/reconstruct-from-mat/reconstruct-from-mat.js +28 -0
  55. package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -0
  56. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +12 -0
  57. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +46 -0
  58. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -0
  59. package/node/reconstruct-from-mat/split-tri-path.d.ts +5 -0
  60. package/node/reconstruct-from-mat/split-tri-path.js +209 -0
  61. package/node/reconstruct-from-mat/split-tri-path.js.map +1 -0
  62. package/node/sat/add-debug-info.js +1 -2
  63. package/node/sat/add-debug-info.js.map +1 -1
  64. package/node/utils/clip.d.ts +2 -0
  65. package/node/utils/clip.js +6 -0
  66. package/node/utils/clip.js.map +1 -0
  67. package/package.json +2 -2
  68. package/src/cp-node/fs/is-on-same-loop.ts +15 -0
  69. package/src/debug/debug.ts +54 -72
  70. package/src/find-2-prong/add-1-prong.ts +1 -5
  71. package/src/find-mat/find-mat.ts +1 -2
  72. package/src/find-mat/get-meta.ts +3 -38
  73. package/src/index.ts +5 -3
  74. package/src/reconstruct-from-mat/filter-zero-length.ts +23 -0
  75. package/src/reconstruct-from-mat/get-all-on-loop-by-loop.ts +52 -0
  76. package/src/reconstruct-from-mat/get-bezier-piece-length.ts +12 -0
  77. package/src/reconstruct-from-mat/get-boundary.ts +32 -0
  78. package/src/reconstruct-from-mat/get-cp-nodess-for-sat.ts +24 -0
  79. package/src/reconstruct-from-mat/get-matching-beziers.ts +46 -0
  80. package/src/reconstruct-from-mat/get-mbss-by-loop-per-sat.ts +19 -0
  81. package/src/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.ts +69 -0
  82. package/src/reconstruct-from-mat/get-sats2.ts +25 -0
  83. package/src/reconstruct-from-mat/is-fully-terminating.ts +27 -0
  84. package/src/reconstruct-from-mat/matched-beziers.ts +14 -0
  85. package/src/reconstruct-from-mat/reconstruct-from-mat.ts +45 -0
  86. package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +62 -0
  87. package/src/reconstruct-from-mat/split-tri-path.ts +280 -0
  88. package/src/sat/add-debug-info.ts +1 -2
  89. package/src/utils/clip.ts +13 -0
  90. package/node/debug/functions/general.d.ts +0 -48
  91. package/node/debug/functions/general.js +0 -53
  92. package/node/debug/functions/general.js.map +0 -1
  93. package/node/point-on-shape/pos-to-human-string.d.ts +0 -8
  94. package/node/point-on-shape/pos-to-human-string.js +0 -12
  95. package/node/point-on-shape/pos-to-human-string.js.map +0 -1
  96. package/src/debug/elem-type-two-prong.ts +0 -8
  97. package/src/debug/functions/cmp-cp-on-delta.ts +0 -54
  98. package/src/debug/functions/general.ts +0 -79
  99. package/src/debug/functions/three-prong.ts +0 -249
  100. package/src/debug/functions/two-prong.ts +0 -203
  101. package/src/find-2-prong/add-debug-info.ts +0 -45
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mbss-by-loop-per-sat.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/get-mbss-by-loop-per-sat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,SAAS,mBAAmB,CACpB,IAAW,EACX,QAAgB;IAEpB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEtC,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAEnD,OAAO,cAAc,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AACvD,CAAC;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { CpNode } from "../cp-node/cp-node.js";
2
+ import type { MatchedBeziers } from "./matched-beziers.js";
3
+ declare function getMbssByLoopWithOppArr(cpNodess: CpNode[][]): {
4
+ mbssByLoop: (MatchedBeziers[] | undefined)[][];
5
+ oppArr: [[number, number], [number, number]][];
6
+ };
7
+ export { getMbssByLoopWithOppArr };
@@ -0,0 +1,47 @@
1
+ import { getMatchingBeziers } from "./get-matching-beziers.js";
2
+ import { isFullyTerminating } from "./is-fully-terminating.js";
3
+ function getMbssByLoopWithOppArr(cpNodess) {
4
+ const mbssByLoop = [];
5
+ /**
6
+ * An array with each entry being a pair of indices mapping from
7
+ * `MatchedBeziers[]` on one side to `MatchedBeziers[]` on the other side
8
+ */
9
+ const mbMap = new Map();
10
+ for (let l = 0; l < cpNodess.length; l++) {
11
+ const cpNodes = cpNodess[l];
12
+ const mbss = [];
13
+ for (let i = 0; i < cpNodes.length; i++) {
14
+ const cpNode = cpNodes[i];
15
+ mbMap.set(cpNode, [l, i]);
16
+ const mbs = getMatchingBeziers(cpNode);
17
+ mbss.push(mbs);
18
+ }
19
+ mbssByLoop.push(mbss);
20
+ }
21
+ const oppArr = [];
22
+ for (let l = 0; l < cpNodess.length; l++) {
23
+ const cpNodes = cpNodess[l];
24
+ for (let i = 0; i < cpNodes.length; i++) {
25
+ const cpNode = cpNodes[i];
26
+ const cpNodeOpp = isFullyTerminating(cpNode)
27
+ ? undefined // no opposite boundary
28
+ : cpNode.next.prevOnCircle;
29
+ // if (cpNodeOpp === undefined) {
30
+ // continue;
31
+ // }
32
+ const oppIdxs = cpNodeOpp === undefined
33
+ ? [255, 65535]
34
+ : mbMap.get(cpNodeOpp);
35
+ const mbs = mbssByLoop[l][i];
36
+ if (oppIdxs !== undefined && mbs !== undefined) {
37
+ oppArr.push([[l, i], oppIdxs]);
38
+ }
39
+ else {
40
+ oppArr.push([[l, i], [255, 65535]]);
41
+ }
42
+ }
43
+ }
44
+ return { mbssByLoop, oppArr };
45
+ }
46
+ export { getMbssByLoopWithOppArr };
47
+ //# sourceMappingURL=get-mbss-by-loop-with-opp-arr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mbss-by-loop-with-opp-arr.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,SAAS,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YAAY,CAAC;YAE/B,iCAAiC;YACjC,gBAAgB;YAChB,IAAI;YAEJ,MAAM,OAAO,GAAG,SAAS,KAAK,SAAS;gBACnC,CAAC,CAAC,CAAC,GAAG,EAAC,KAAK,CAAoB;gBAChC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAE3B,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAI,OAAO,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBAC7C,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC;AAGD,OAAO,EAAE,uBAAuB,EAAE,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { Mat } from '../mat/mat.js';
2
+ /**
3
+ * Returns the shape information.
4
+ *
5
+ * @param font$$ the font from which the glyph outlines will be retrieved
6
+ * @param glyphId the glyph id for which the shape is to be retrieved
7
+ * @param options the options for SAT computation
8
+ */
9
+ declare function getSats2(mats: Mat[], satScale: number): Mat[];
10
+ export { getSats2 };
@@ -0,0 +1,16 @@
1
+ import { removeSatInducedTrivial3Prongs } from "./remove-sat-induced-trivial-3prongs.js";
2
+ import { toScaleAxis } from '../sat/to-scale-axis.js';
3
+ /**
4
+ * Returns the shape information.
5
+ *
6
+ * @param font$$ the font from which the glyph outlines will be retrieved
7
+ * @param glyphId the glyph id for which the shape is to be retrieved
8
+ * @param options the options for SAT computation
9
+ */
10
+ // TODO
11
+ function getSats2(mats, satScale) {
12
+ const sats = mats.map(mat => toScaleAxis(mat, satScale));
13
+ return sats.map(removeSatInducedTrivial3Prongs);
14
+ }
15
+ export { getSats2 };
16
+ //# sourceMappingURL=get-sats2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-sats2.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/get-sats2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD;;;;;;GAMG;AACH,OAAO;AACP,SAAS,QAAQ,CACT,IAAW,EACX,QAAgB;IAEpB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEzD,OAAO,IAAI,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AACpD,CAAC;AAGD,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { CpNode } from '../cp-node/cp-node.js';
2
+ declare function isFullyTerminating(cpNode: CpNode): boolean;
3
+ export { isFullyTerminating };
@@ -0,0 +1,19 @@
1
+ import { getAllOnCircle } from '../cp-node/fs/get-all-on-circle.js';
2
+ import { isTerminating } from '../cp-node/fs/is-terminating.js';
3
+ import { isTrivial } from '../cp-node/fs/is-trivial.js';
4
+ // TODO - DUPLICATE! -> likely other version needs fixing
5
+ function isFullyTerminating(cpNode) {
6
+ if (!isTerminating(cpNode)) {
7
+ return false;
8
+ }
9
+ if (isTrivial(cpNode)) {
10
+ return true;
11
+ }
12
+ while (cpNode.prev === cpNode.prevOnCircle) {
13
+ cpNode = cpNode.prev;
14
+ }
15
+ const otherOnCircle = getAllOnCircle(cpNode.prevOnCircle, true);
16
+ return otherOnCircle.every(isTerminating);
17
+ }
18
+ export { isFullyTerminating };
19
+ //# sourceMappingURL=is-fully-terminating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-fully-terminating.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/is-fully-terminating.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAGxD,yDAAyD;AACzD,SAAS,kBAAkB,CAAC,MAAc;IACtC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC;QACzC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAEhE,OAAO,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAC9C,CAAC;AAGD,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { BezierPiece } from 'flo-bezier3';
2
+ /**
3
+ * A type representing a correspondence between 3 bezier curves (one on the
4
+ * boundary, one on the medial axis and one on the opposite boundary)
5
+ */
6
+ interface MatchedBeziers {
7
+ readonly medialBezier: BezierPiece;
8
+ readonly boundaryBezier: BezierPiece;
9
+ }
10
+ export type { MatchedBeziers };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=matched-beziers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matched-beziers.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/matched-beziers.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { BezierPiece } from 'flo-bezier3';
2
+ import type { Mat } from '../mat/mat.js';
3
+ declare function reconstructFromMats(mats: Mat[]): BezierPiece[];
4
+ export { reconstructFromMats };
@@ -0,0 +1,28 @@
1
+ import { getMbssByLoopPerSat } from './get-mbss-by-loop-per-sat.js';
2
+ function reconstructFromMats(mats) {
3
+ const loopss = [];
4
+ const bzs = [];
5
+ const mbssByLoopPerSat = getMbssByLoopPerSat(mats, 1.5);
6
+ for (const mbssByLoopPS of mbssByLoopPerSat) {
7
+ const { mbssByLoop, oppArr } = mbssByLoopPS;
8
+ for (let l = 0; l < mbssByLoop.length; l++) {
9
+ const rs = mbssByLoop[l];
10
+ for (let i = 0; i < rs.length; i++) {
11
+ const r = mbssByLoop[l][i];
12
+ if (r === undefined) {
13
+ continue;
14
+ }
15
+ const matchedBezierss = r;
16
+ for (let j = 0; j < matchedBezierss.length; j++) {
17
+ const mb = matchedBezierss[j];
18
+ const { boundaryBezier, medialBezier } = mb;
19
+ bzs.push(boundaryBezier);
20
+ }
21
+ }
22
+ }
23
+ }
24
+ return bzs;
25
+ // return loopss;
26
+ }
27
+ export { reconstructFromMats };
28
+ //# sourceMappingURL=reconstruct-from-mat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconstruct-from-mat.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/reconstruct-from-mat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,SAAS,mBAAmB,CACpB,IAAW;IAEf,MAAM,MAAM,GAAmB,EAAE,CAAC;IAElC,MAAM,GAAG,GAAkB,EAAE,CAAC;IAE9B,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAE,CAAC;IAEzD,KAAK,MAAM,YAAY,IAAI,gBAAgB,EAAE,CAAC;QAC1C,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC;QAE5C,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAEzB,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC7B,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE3B,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;oBAAC,SAAS;gBAAC,CAAC;gBAElC,MAAM,eAAe,GAAG,CAAC,CAAC;gBAE1B,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC1C,MAAM,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;oBAC9B,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;oBAE5C,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;gBAC5B,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAGD,OAAO,GAAG,CAAC;IACX,iBAAiB;AACrB,CAAC;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Mat } from '../mat/mat.js';
2
+ /**
3
+ * In-place removes trivial 3-prongs from the SAT graph; just to simplify
4
+ * subsequent processing.
5
+ *
6
+ * These are 3-prongs that are induced by the SAT construction, and do
7
+ * not correspond to actual 3-prongs in the shape.
8
+ *
9
+ * @param sat the SAT
10
+ */
11
+ declare function removeSatInducedTrivial3Prongs(sat: Mat): Mat;
12
+ export { removeSatInducedTrivial3Prongs };
@@ -0,0 +1,46 @@
1
+ import { isFullyTerminating } from './is-fully-terminating.js';
2
+ /**
3
+ * In-place removes trivial 3-prongs from the SAT graph; just to simplify
4
+ * subsequent processing.
5
+ *
6
+ * These are 3-prongs that are induced by the SAT construction, and do
7
+ * not correspond to actual 3-prongs in the shape.
8
+ *
9
+ * @param sat the SAT
10
+ */
11
+ function removeSatInducedTrivial3Prongs(sat) {
12
+ let { cpNode } = sat;
13
+ let cpStart = cpNode;
14
+ do {
15
+ if (isFullyTerminating(cpNode) ||
16
+ // cpNode.isHoleClosing || // hole-closers are fully terminating
17
+ cpNode.next !== cpNode.nextOnCircle) {
18
+ cpNode = cpNode.next;
19
+ continue;
20
+ }
21
+ //-----------------------------
22
+ // Delete the trivial 3-prong
23
+ //-----------------------------
24
+ // console.log('Removing SAT-induced trivial 3-prong');
25
+ const next = cpNode.next;
26
+ const nextNext = next.next;
27
+ const nextNextOC = cpNode.next.nextOnCircle;
28
+ //-------------------------------------------------------------
29
+ // In-place update of links to remove the trivial 3-prong node
30
+ //-------------------------------------------------------------
31
+ cpNode.next = nextNext;
32
+ cpNode.nextOnCircle = nextNextOC;
33
+ nextNext.prev = cpNode;
34
+ nextNextOC.prevOnCircle = cpNode;
35
+ //-------------------------------------------------------------
36
+ if (cpStart === next) {
37
+ cpStart = cpNode; // ...otherwise the loop will never terminate
38
+ }
39
+ cpNode = cpNode.next;
40
+ } while (cpNode !== cpStart);
41
+ // ...otherwise the caller will have a reference to a node that has been removed from the graph
42
+ sat.cpNode = cpNode;
43
+ return sat;
44
+ }
45
+ export { removeSatInducedTrivial3Prongs };
46
+ //# sourceMappingURL=remove-sat-induced-trivial-3prongs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-sat-induced-trivial-3prongs.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D;;;;;;;;GAQG;AACH,SAAS,8BAA8B,CAC/B,GAAQ;IAEZ,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAErB,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,GAAG,CAAC;QACA,IAAI,kBAAkB,CAAC,MAAM,CAAC;YAC1B,iEAAiE;YACjE,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC;YAEtC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;YACrB,SAAS;QACb,CAAC;QAED,+BAA+B;QAC/B,6BAA6B;QAC7B,+BAA+B;QAC/B,uDAAuD;QAEvD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;QAE5C,+DAA+D;QAC/D,8DAA8D;QAC9D,+DAA+D;QAC9D,MAAiC,CAAC,IAAI,GAAG,QAAQ,CAAC;QAClD,MAAiC,CAAC,YAAY,GAAG,UAAU,CAAC;QAC5D,QAAqC,CAAC,IAAI,GAAG,MAAM,CAAC;QACpD,UAAyC,CAAC,YAAY,GAAG,MAAM,CAAC;QACjE,+DAA+D;QAE/D,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,GAAG,MAAM,CAAC,CAAE,6CAA6C;QACpE,CAAC;QAED,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC,QAAQ,MAAM,KAAK,OAAO,EAAC;IAE5B,+FAA+F;IAC9F,GAAoB,CAAC,MAAM,GAAG,MAAM,CAAC;IAEtC,OAAO,GAAG,CAAC;AACf,CAAC;AAGD,OAAO,EAAE,8BAA8B,EAAE,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { BezierPiece } from 'flo-bezier3';
2
+ import type { MatchedBeziers } from './matched-beziers.js';
3
+ declare function splitTriPath(boundaryBeziers: BezierPiece[], medialBezier: BezierPiece, boundaryBeziersOpp: BezierPiece[] | undefined): MatchedBeziers[];
4
+ declare function getCumLengths(lens: number[]): number[];
5
+ export { splitTriPath, getCumLengths };
@@ -0,0 +1,209 @@
1
+ import { getTAtLength } from 'flo-bezier3';
2
+ import { sum } from '../utils/sum.js';
3
+ import { clip } from '../utils/clip.js';
4
+ import { getBezierPieceLength } from './get-bezier-piece-length.js';
5
+ const EPS = 1e-9;
6
+ function splitTriPath(boundaryBeziers, medialBezier, boundaryBeziersOpp) {
7
+ const _boundaryBeziersOpp = boundaryBeziersOpp ?? [];
8
+ const boundaryBeziersOpp_ = _boundaryBeziersOpp.map(reverseBezierPiece).toReversed();
9
+ // Importantly, we need to split on boundaryBeziersOpp_ as well, to ensure
10
+ // the number of returned pieces is the same for both sides, so that they
11
+ // can be interpolated.
12
+ const _paths = boundaryBeziersOpp_.length > 0
13
+ ? [boundaryBeziers, [medialBezier], boundaryBeziersOpp_]
14
+ : [boundaryBeziers, [medialBezier]];
15
+ const paths = splitTriPath_(_paths);
16
+ const matchedBezierss = [];
17
+ for (let i = 0; i < paths.length; i++) {
18
+ const path = paths[i];
19
+ // const pathOpp = paths[paths.length - 1 - i];
20
+ const [boundaryBezier, medialBezier] = path;
21
+ // const boundaryBezierOpp = pathOpp[2];
22
+ const matchedBeziers = {
23
+ boundaryBezier,
24
+ medialBezier,
25
+ // boundaryBezierOpp
26
+ };
27
+ matchedBezierss.push(matchedBeziers);
28
+ }
29
+ return matchedBezierss;
30
+ }
31
+ function reverseBezierPiece(bezierPiece) {
32
+ const { ps, ts: [tS, tE] } = bezierPiece;
33
+ return {
34
+ ps: ps.toReversed(),
35
+ ts: [1 - tE, 1 - tS]
36
+ };
37
+ }
38
+ /**
39
+ * Returns an array of arrays of `BezierPiece`s, where each inner array
40
+ * contains `BezierPiece`s that correspond to each other across the different
41
+ * paths by normalized length.
42
+ *
43
+ * For example, if there are 3 paths, then each inner array will contain 3
44
+ * `BezierPiece`s, one from each path, that correspond to each other by normalized
45
+ * length.
46
+ *
47
+ * @param bezierPiecess
48
+ */
49
+ function splitTriPath_(bezierPiecess) {
50
+ const lenss = mapmap(bezierPiecess, getBezierPieceLength);
51
+ const lens = lenss.map(sum);
52
+ const cums = lenss.map(getCumLengths);
53
+ const normCums = cums.map((cum, i) => {
54
+ const len = lens[i];
55
+ if (len <= EPS) {
56
+ return cum.map((_, j) => j === 0 ? 0 : 1);
57
+ // return cum.map(() => Number.POSITIVE_INFINITY);
58
+ }
59
+ return cum.map(l => l / len);
60
+ });
61
+ /** Current position of start t */
62
+ let ts = new Array(bezierPiecess.length).fill(0);
63
+ /** Current position of i */
64
+ let is = new Array(bezierPiecess.length).fill(0);
65
+ const matchedBezierss = [];
66
+ normCums; //?
67
+ let ii = 0;
68
+ const maxIterations = 100;
69
+ while (ts.some(t => t < 1) && ii++ < maxIterations) {
70
+ const normCumsNext = [];
71
+ for (let k = 0; k < bezierPiecess.length; k++) {
72
+ const i_ = is[k];
73
+ const normCum_ = normCums[k][i_ + 1]; //?
74
+ const normCum = normCum_ === undefined
75
+ ? Number.POSITIVE_INFINITY
76
+ : normCum_;
77
+ normCumsNext.push(normCum);
78
+ }
79
+ normCumsNext; //?
80
+ const minIdx = getMinIdx(normCumsNext); //?
81
+ const idxs = getIdxs(normCumsNext, normCumsNext[minIdx]); //?
82
+ const curCum = normCumsNext[minIdx];
83
+ // if (idxs.length === 0) {
84
+ // throw new Error('splitTriPath_: unable to make progress');
85
+ // }
86
+ const nextPieces = new Array(bezierPiecess.length).fill([]);
87
+ for (let m = 0; m < bezierPiecess.length; m++) {
88
+ const bezierPieces = bezierPiecess[m];
89
+ const _i = is[m];
90
+ // This path is already finished; keep emitting a degenerate tail.
91
+ if (_i >= bezierPieces.length) {
92
+ const lastBezierPiece = bezierPieces[bezierPieces.length - 1];
93
+ nextPieces[m] = {
94
+ ps: lastBezierPiece.ps,
95
+ ts: [1, 1]
96
+ };
97
+ ts[m] = 1;
98
+ continue;
99
+ }
100
+ if (idxs.includes(m)) {
101
+ const _t = ts[m];
102
+ const bezierPiece = bezierPieces[_i];
103
+ const [pieceTS, pieceTE] = bezierPiece.ts;
104
+ const pieceDt = pieceTE - pieceTS;
105
+ nextPieces[m] = {
106
+ ps: bezierPiece.ps,
107
+ ts: [pieceTS + _t * pieceDt, pieceTE]
108
+ };
109
+ const nextI = _i + 1;
110
+ is[m] = nextI;
111
+ ts[m] = nextI >= bezierPieces.length ? 1 : 0;
112
+ }
113
+ else {
114
+ const _t = ts[m];
115
+ const bezierPiece = bezierPieces[_i];
116
+ const [pieceTS, pieceTE] = bezierPiece.ts;
117
+ const pieceDt = pieceTE - pieceTS;
118
+ const bezierLen = getBezierPieceLength({ ps: bezierPiece.ps, ts: [0, 1] });
119
+ const normCumStart = normCums[m][_i];
120
+ const normCumEnd = normCums[m][_i + 1];
121
+ const normCumDt = normCumEnd - normCumStart;
122
+ const normWithinPiece = normCumDt <= EPS
123
+ ? _t
124
+ : clip((curCum - normCumStart) / normCumDt, _t, 1);
125
+ const t1 = bezierLen <= EPS
126
+ ? _t
127
+ : clip(getTAtLength(bezierPiece.ps, bezierLen * normWithinPiece), _t, 1);
128
+ nextPieces[m] = {
129
+ ps: bezierPiece.ps,
130
+ ts: [pieceTS + _t * pieceDt, pieceTS + t1 * pieceDt]
131
+ };
132
+ if (closeToEps(t1, 1)) {
133
+ const nextI = _i + 1;
134
+ is[m] = nextI;
135
+ ts[m] = nextI >= bezierPieces.length ? 1 : 0;
136
+ }
137
+ else {
138
+ is[m] = _i;
139
+ ts[m] = t1;
140
+ }
141
+ }
142
+ }
143
+ matchedBezierss.push(nextPieces);
144
+ }
145
+ if (ts.some(t => t < 1)) {
146
+ throw new Error('splitTriPath_: exceeded maximum iterations');
147
+ }
148
+ return matchedBezierss;
149
+ }
150
+ function getCumLengths(lens) {
151
+ const cum = [0];
152
+ let cumLen = 0;
153
+ for (let j = 0; j < lens.length; j++) {
154
+ cumLen += lens[j];
155
+ cum.push(cumLen);
156
+ }
157
+ return cum;
158
+ }
159
+ /**
160
+ * Returns the index within the given array of the number with the highest
161
+ * value.
162
+ *
163
+ * * returns `undefined` if the array is empty
164
+ */
165
+ function getMinIdx(vs) {
166
+ let minIdx = undefined;
167
+ let minVal = Number.POSITIVE_INFINITY;
168
+ for (let i = 0; i < vs.length; i++) {
169
+ if (vs[i] <= minVal) {
170
+ minVal = vs[i];
171
+ minIdx = i;
172
+ }
173
+ }
174
+ return minIdx;
175
+ }
176
+ /**
177
+ * Returns the indices within the given array of the numbers that are equal to
178
+ * the given max value (within an EPS value).
179
+ *
180
+ * @param vs
181
+ * @param maxVal
182
+ */
183
+ function getIdxs(vs, maxVal) {
184
+ const maxIdxs = [];
185
+ for (let i = 0; i < vs.length; i++) {
186
+ if (vs[i] === maxVal || closeToEps(vs[i], maxVal)) {
187
+ maxIdxs.push(i);
188
+ }
189
+ }
190
+ return maxIdxs;
191
+ }
192
+ function closeToEps(a, b) {
193
+ return Math.abs(a - b) <= EPS;
194
+ }
195
+ export { splitTriPath, getCumLengths };
196
+ // KEEP FOR TESTING! - one in opentype-ts doesn't work with tests due to aliases
197
+ function mapmap(tss, f) {
198
+ const tss_ = [];
199
+ for (let i = 0; i < tss.length; i++) {
200
+ const ts = tss[i];
201
+ const ts_ = [];
202
+ for (let j = 0; j < ts.length; j++) {
203
+ ts_.push(f(ts[j]));
204
+ }
205
+ tss_.push(ts_);
206
+ }
207
+ return tss_;
208
+ }
209
+ //# sourceMappingURL=split-tri-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split-tri-path.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/split-tri-path.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,MAAM,GAAG,GAAG,IAAI,CAAC;AAGjB,SAAS,YAAY,CACb,eAA8B,EAC9B,YAAyB,EACzB,kBAA6C;IAEjD,MAAM,mBAAmB,GAAG,kBAAkB,IAAI,EAA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IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAGD,SAAS,UAAU,CAAC,CAAS,EAAE,CAAS;IACpC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;AAClC,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAIvC,gFAAgF;AAChF,SAAS,MAAM,CACP,GAAU,EACV,CAAc;IAElB,MAAM,IAAI,GAAU,EAAE,CAAC;IACvB,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -7,8 +7,7 @@ function addDebugInfo(timingStart) {
7
7
  if (typeof _debug_ === 'undefined') {
8
8
  return;
9
9
  }
10
- const timing = _debug_.generated.timing;
11
- timing.sats = performance.now() - timingStart;
10
+ _debug_.timing.sats = performance.now() - timingStart;
12
11
  }
13
12
  export { addDebugInfo };
14
13
  //# sourceMappingURL=add-debug-info.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-debug-info.js","sourceRoot":"","sources":["../../src/sat/add-debug-info.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,SAAS,YAAY,CACb,WAAmB;IAEvB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QAAC,OAAO;IAAC,CAAC;IAE/C,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;IACxC,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC;AAClD,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"add-debug-info.js","sourceRoot":"","sources":["../../src/sat/add-debug-info.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,SAAS,YAAY,CACb,WAAmB;IAEvB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QAAC,OAAO;IAAC,CAAC;IAE/C,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC;AAC1D,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare function clip(v: number, vMin: number, vMax: number): number;
2
+ export { clip };
@@ -0,0 +1,6 @@
1
+ const { max, min } = Math;
2
+ function clip(v, vMin, vMax) {
3
+ return max(vMin, min(vMax, v));
4
+ }
5
+ export { clip };
6
+ //# sourceMappingURL=clip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip.js","sourceRoot":"","sources":["../../src/utils/clip.ts"],"names":[],"mappings":"AACA,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1B,SAAS,IAAI,CACL,CAAS,EACT,IAAY,EACZ,IAAY;IAEhB,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAGD,OAAO,EAAE,IAAI,EAAE,CAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "flo-mat",
3
3
  "sideEffects": false,
4
4
  "description": "Medial / Scale Axis Transform (MAT/SAT) Library.",
5
- "version": "4.0.2",
5
+ "version": "4.0.3",
6
6
  "author": {
7
7
  "name": "Floris Steenkamp"
8
8
  },
@@ -34,7 +34,7 @@
34
34
  "big-float-ts": "^4.0.4",
35
35
  "double-double": "^3.0.4",
36
36
  "flo-bezier3": "^8.0.11",
37
- "flo-boolean": "^5.0.5",
37
+ "flo-boolean": "^5.0.7",
38
38
  "flo-draw": "^2.0.5",
39
39
  "flo-gauss-quadrature": "^2.1.4",
40
40
  "flo-ll-rb-tree": "^1.0.1",
@@ -0,0 +1,15 @@
1
+ import type { CpNode } from "flo-mat";
2
+
3
+
4
+ function isOnSameLoop(
5
+ cpNode1: CpNode,
6
+ cpNode2: CpNode): boolean {
7
+
8
+ return (
9
+ cpNode1.pointOnShape.curve.loop ===
10
+ cpNode2.pointOnShape.curve.loop
11
+ );
12
+ }
13
+
14
+
15
+ export { isOnSameLoop }