flo-mat 2.0.0 → 2.0.2
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/.eslintrc.cjs +69 -0
- package/README.md +9 -27
- package/browser/index.js +29720 -7345
- package/browser/index.min.js +1 -2
- package/node/circle.js +3 -3
- package/node/circle.js.map +1 -1
- package/node/compare-curvatures-at-interface.js +36 -36
- package/node/compare-curvatures-at-interface.js.map +1 -1
- package/node/cp-node/clone.js +6 -6
- package/node/cp-node/clone.js.map +1 -1
- package/node/cp-node/remove.js +4 -4
- package/node/cp-node/remove.js.map +1 -1
- package/node/cp-node.js +18 -18
- package/node/cp-node.js.map +1 -1
- package/node/curve.d.ts +1 -1
- package/node/curve.js +19 -19
- package/node/curve.js.map +1 -1
- package/node/debug/debug.d.ts +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/branch.js +4 -4
- package/node/debug/functions/draw-elem/branch.js.map +1 -1
- package/node/debug/functions/draw-elem/culls.js +4 -4
- package/node/debug/functions/draw-elem/culls.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.js +1 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +2 -2
- package/node/debug/functions/draw-elem/draw-elem.js +1 -1
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/dull-corner.js +3 -3
- package/node/debug/functions/draw-elem/dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/leaves.js +4 -4
- package/node/debug/functions/draw-elem/leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/loose-bounding-box.js +2 -2
- package/node/debug/functions/draw-elem/loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/mat.js +4 -4
- package/node/debug/functions/draw-elem/mat.js.map +1 -1
- package/node/debug/functions/draw-elem/max-vertex.js +2 -2
- package/node/debug/functions/draw-elem/max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/min-y.js +3 -3
- package/node/debug/functions/draw-elem/min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +4 -4
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong.js +4 -4
- package/node/debug/functions/draw-elem/one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/sharp-corner.js +2 -2
- package/node/debug/functions/draw-elem/sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/three-prong.js +7 -7
- package/node/debug/functions/draw-elem/three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/tight-bounding-box.js +1 -1
- package/node/debug/functions/draw-elem/tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/two-prong.js +1 -1
- package/node/debug/functions/draw-elem/two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/vertex.js +13 -13
- package/node/debug/functions/draw-elem/vertex.js.map +1 -1
- package/node/debug/functions/general.d.ts +1 -1
- package/node/debug/functions/general.js +1 -1
- package/node/debug/functions/general.js.map +1 -1
- package/node/debug/functions/three-prong.d.ts +1 -1
- package/node/debug/functions/three-prong.js +37 -37
- package/node/debug/functions/three-prong.js.map +1 -1
- package/node/debug/functions/two-prong.d.ts +1 -1
- package/node/debug/functions/two-prong.js +15 -15
- package/node/debug/functions/two-prong.js.map +1 -1
- package/node/find-mats.js +16 -19
- package/node/find-mats.js.map +1 -1
- package/node/get-boundary-bezier-parts-to-next.js +8 -8
- package/node/get-boundary-bezier-parts-to-next.js.map +1 -1
- package/node/get-boundary-beziers-to-next.js +8 -8
- package/node/get-boundary-beziers-to-next.js.map +1 -1
- package/node/get-branches.js +7 -7
- package/node/get-branches.js.map +1 -1
- package/node/get-curve/get-curve-between.js +21 -21
- package/node/get-curve/get-curve-between.js.map +1 -1
- package/node/get-curve/get-edge-direction.js +13 -13
- package/node/get-curve/get-edge-direction.js.map +1 -1
- package/node/get-interface-ccw.js +12 -12
- package/node/get-interface-ccw.js.map +1 -1
- package/node/loop/get-max-coordinate.js +9 -9
- package/node/loop/get-max-coordinate.js.map +1 -1
- package/node/loop.js +4 -4
- package/node/loop.js.map +1 -1
- package/node/mat/add-to-cp-graph.js +8 -8
- package/node/mat/add-to-cp-graph.js.map +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +5 -6
- package/node/mat/closest-boundary-point/closest-points-on-curve.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +1 -1
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +5 -5
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +5 -5
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
- package/node/mat/closest-boundary-point/get-best-distance-squared.js +5 -5
- package/node/mat/closest-boundary-point/get-best-distance-squared.js.map +1 -1
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +15 -15
- package/node/mat/closest-boundary-point/get-close-boundary-points.js.map +1 -1
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +4 -4
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js.map +1 -1
- package/node/mat/create-new-cp-tree.js +3 -3
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/elem-type-two-prong.d.ts +1 -1
- package/node/mat/find-mat/add-1-prong.js +3 -3
- package/node/mat/find-mat/add-1-prong.js.map +1 -1
- package/node/mat/find-mat/add-2-prong.js +40 -40
- package/node/mat/find-mat/add-2-prong.js.map +1 -1
- package/node/mat/find-mat/add-3-prong.js +1 -1
- package/node/mat/find-mat/add-3-prong.js.map +1 -1
- package/node/mat/find-mat/add-debug-info.js +16 -18
- package/node/mat/find-mat/add-debug-info.js.map +1 -1
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +4 -4
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js.map +1 -1
- package/node/mat/find-mat/create-initial-cp-graph.js +11 -11
- package/node/mat/find-mat/create-initial-cp-graph.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +2 -2
- package/node/mat/find-mat/find-2-prong/add-debug-info.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +5 -5
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/find-2-prong.js +25 -25
- package/node/mat/find-mat/find-2-prong/find-2-prong.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +7 -7
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +4 -4
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +1 -1
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +4 -4
- package/node/mat/find-mat/find-3-prong/calc-better-x.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +3 -3
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +35 -35
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/find-3-prong.js +14 -14
- package/node/mat/find-mat/find-3-prong/find-3-prong.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/get-closest-points.js +1 -1
- package/node/mat/find-mat/find-3-prong/get-closest-points.js.map +1 -1
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +2 -2
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js.map +1 -1
- package/node/mat/find-mat/find-and-add-2-prongs.js +12 -13
- package/node/mat/find-mat/find-and-add-2-prongs.js.map +1 -1
- package/node/mat/find-mat/find-and-add-3-prongs.js +16 -17
- package/node/mat/find-mat/find-and-add-3-prongs.js.map +1 -1
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +6 -6
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-potential-2-prongs.js +4 -4
- package/node/mat/find-mat/get-potential-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-sharp-corners.js +4 -4
- package/node/mat/find-mat/get-sharp-corners.js.map +1 -1
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +3 -3
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.js +5 -5
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-contact-circles-at-interface.js +1 -1
- package/node/mat/get-contact-circles-at-interface.js.map +1 -1
- package/node/mat/get-leaves.js +2 -2
- package/node/mat/get-leaves.js.map +1 -1
- package/node/mat/get-neighboring-cps.js +1 -1
- package/node/mat/get-neighboring-cps.js.map +1 -1
- package/node/mat/is-another-cp-closeby.js +9 -9
- package/node/mat/is-another-cp-closeby.js.map +1 -1
- package/node/mat/simplify-mat-map-only.js +15 -15
- package/node/mat/simplify-mat-map-only.js.map +1 -1
- package/node/mat/to-scale-axis/add-debug-info.js +1 -1
- package/node/mat/to-scale-axis/add-debug-info.js.map +1 -1
- package/node/mat/to-scale-axis/cull-non-cycles.js +5 -5
- package/node/mat/to-scale-axis/cull-non-cycles.js.map +1 -1
- package/node/mat/to-scale-axis/cull.js +5 -5
- package/node/mat/to-scale-axis/cull.js.map +1 -1
- package/node/mat/trim-mat.js +1 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/point-on-shape.d.ts +4 -4
- package/node/point-on-shape.js +16 -16
- package/node/point-on-shape.js.map +1 -1
- package/node/simplify-mat.js +10 -10
- package/node/simplify-mat.js.map +1 -1
- package/node/svg/get-loop-bounds.d.ts +1 -1
- package/node/svg/get-loop-bounds.js +13 -13
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-shape-bounds.d.ts +2 -2
- package/node/svg/get-shape-bounds.js +4 -4
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.js +8 -8
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/to-scale-axis.js +16 -15
- package/node/to-scale-axis.js.map +1 -1
- package/node/traverse-edges.js +2 -2
- package/node/traverse-edges.js.map +1 -1
- package/node/traverse-vertices.js +2 -2
- package/node/traverse-vertices.js.map +1 -1
- package/package.json +30 -25
- package/src/circle.ts +3 -3
- package/src/compare-curvatures-at-interface.ts +36 -36
- package/src/cp-node/clone.ts +6 -6
- package/src/cp-node/remove.ts +4 -4
- package/src/cp-node.ts +20 -20
- package/src/curve.ts +19 -19
- package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
- package/src/debug/functions/draw-elem/branch.ts +4 -4
- package/src/debug/functions/draw-elem/culls.ts +4 -4
- package/src/debug/functions/draw-elem/draw-circle-percent.ts +2 -2
- package/src/debug/functions/draw-elem/draw-elem.ts +1 -1
- package/src/debug/functions/draw-elem/dull-corner.ts +3 -3
- package/src/debug/functions/draw-elem/leaves.ts +4 -4
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +2 -2
- package/src/debug/functions/draw-elem/mat.ts +4 -4
- package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/min-y.ts +3 -3
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +4 -4
- package/src/debug/functions/draw-elem/one-prong.ts +4 -4
- package/src/debug/functions/draw-elem/sharp-corner.ts +2 -2
- package/src/debug/functions/draw-elem/three-prong.ts +7 -7
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +1 -1
- package/src/debug/functions/draw-elem/two-prong.ts +1 -1
- package/src/debug/functions/draw-elem/vertex.ts +20 -14
- package/src/debug/functions/general.ts +3 -3
- package/src/debug/functions/three-prong.ts +37 -37
- package/src/debug/functions/two-prong.ts +15 -15
- package/src/find-mats.ts +19 -19
- package/src/get-boundary-bezier-parts-to-next.ts +8 -8
- package/src/get-boundary-beziers-to-next.ts +8 -8
- package/src/get-branches.ts +7 -7
- package/src/get-curve/get-curve-between.ts +21 -21
- package/src/get-curve/get-edge-direction.ts +13 -14
- package/src/get-interface-ccw.ts +12 -12
- package/src/loop/get-max-coordinate.ts +7 -7
- package/src/loop.ts +4 -4
- package/src/mat/add-to-cp-graph.ts +8 -8
- package/src/mat/closest-boundary-point/closest-points-on-curve.ts +5 -6
- package/src/mat/closest-boundary-point/cull-bezier-pieces.ts +1 -1
- package/src/mat/closest-boundary-point/cull-by-loose-bounding-box.ts +5 -5
- package/src/mat/closest-boundary-point/cull-by-tight-boundary-box.ts +5 -5
- package/src/mat/closest-boundary-point/get-best-distance-squared.ts +5 -5
- package/src/mat/closest-boundary-point/get-close-boundary-points.ts +15 -15
- package/src/mat/closest-boundary-point/get-closest-boundary-point.ts +4 -4
- package/src/mat/cmp-cp-on-delta.ts +5 -5
- package/src/mat/create-new-cp-tree.ts +3 -3
- package/src/mat/find-mat/add-1-prong.ts +5 -5
- package/src/mat/find-mat/add-2-prong.ts +42 -42
- package/src/mat/find-mat/add-3-prong.ts +1 -1
- package/src/mat/find-mat/add-debug-info.ts +18 -20
- package/src/mat/find-mat/create-get-interesting-points-on-loop.ts +4 -4
- package/src/mat/find-mat/create-initial-cp-graph.ts +11 -11
- package/src/mat/find-mat/find-2-prong/add-debug-info.ts +4 -4
- package/src/mat/find-mat/find-2-prong/cull-bezier-pieces.ts +5 -5
- package/src/mat/find-mat/find-2-prong/find-2-prong.ts +27 -27
- package/src/mat/find-mat/find-2-prong/find-equidistant-point-on-line.ts +7 -7
- package/src/mat/find-mat/find-2-prong/get-initial-bezier-pieces.ts +4 -4
- package/src/mat/find-mat/find-3-prong/calc-better-x.ts +4 -4
- package/src/mat/find-mat/find-3-prong/calc-initial-3-prong-center.ts +3 -3
- package/src/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.ts +37 -37
- package/src/mat/find-mat/find-3-prong/find-3-prong.ts +16 -16
- package/src/mat/find-mat/find-3-prong/get-closest-points.ts +1 -1
- package/src/mat/find-mat/find-and-add-2-prongs-on-all-paths.ts +2 -2
- package/src/mat/find-mat/find-and-add-2-prongs.ts +14 -16
- package/src/mat/find-mat/find-and-add-3-prongs.ts +19 -19
- package/src/mat/find-mat/find-and-add-hole-closing-2-prongs.ts +6 -6
- package/src/mat/find-mat/get-potential-2-prongs.ts +4 -4
- package/src/mat/find-mat/get-sharp-corners.ts +4 -4
- package/src/mat/find-mat/get-total-abs-curvature.ts +1 -1
- package/src/mat/geometry/get-closest-squared-distance-to-rotated-rect.ts +3 -3
- package/src/mat/get-boundary-piece-beziers.ts +5 -5
- package/src/mat/get-contact-circles-at-interface.ts +1 -1
- package/src/mat/get-edges-as-array.ts +2 -2
- package/src/mat/get-leaves.ts +2 -2
- package/src/mat/get-neighboring-cps.ts +1 -1
- package/src/mat/is-another-cp-closeby.ts +9 -9
- package/src/mat/simplify-mat-map-only.ts +15 -15
- package/src/mat/to-scale-axis/add-debug-info.ts +6 -3
- package/src/mat/to-scale-axis/add-to-tree.ts +10 -10
- package/src/mat/to-scale-axis/calc-groups.ts +19 -19
- package/src/mat/to-scale-axis/create-spacial-tree.ts +4 -4
- package/src/mat/to-scale-axis/cull-non-cycles.ts +5 -5
- package/src/mat/to-scale-axis/cull.ts +5 -5
- package/src/mat/to-scale-axis/get-engulfed-vertices.ts +18 -18
- package/src/mat/trim-mat.ts +1 -1
- package/src/point-on-shape.ts +16 -16
- package/src/simplify-mat.ts +10 -10
- package/src/svg/get-curvature-at-interface.ts +6 -8
- package/src/svg/get-extreme.ts +1 -1
- package/src/svg/get-loop-bounds.ts +13 -13
- package/src/svg/get-shape-bounds.ts +4 -4
- package/src/sweep-line/are-boxes-intersecting.ts +4 -4
- package/src/sweep-line/sweep-line.ts +8 -8
- package/src/to-scale-axis.ts +18 -17
- package/src/traverse-edges.ts +2 -2
- package/src/traverse-vertices.ts +2 -2
- package/webpack.config.cjs +12 -63
- package/browser/index.min.js.LICENSE.txt +0 -2907
- package/browser/index.module.js +0 -7369
- package/browser/index.module.min.js +0 -2
- package/browser/index.module.min.js.LICENSE.txt +0 -2907
|
@@ -6,8 +6,8 @@ import { getLoopBounds } from './get-loop-bounds.js';
|
|
|
6
6
|
// TODO - move to another library
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
/** @
|
|
10
|
-
|
|
9
|
+
/** @internal */
|
|
10
|
+
const getShapeBounds = memoize(function(loops: Loop[]) {
|
|
11
11
|
let minX_ = Number.POSITIVE_INFINITY;
|
|
12
12
|
let maxX_ = Number.NEGATIVE_INFINITY;
|
|
13
13
|
let minY_ = Number.POSITIVE_INFINITY;
|
|
@@ -18,8 +18,8 @@ let getShapeBounds = memoize(function(loops: Loop[]) {
|
|
|
18
18
|
let minY;
|
|
19
19
|
let maxY;
|
|
20
20
|
|
|
21
|
-
for (
|
|
22
|
-
|
|
21
|
+
for (const loop of loops) {
|
|
22
|
+
const bounds = getLoopBounds(loop);
|
|
23
23
|
if (bounds.minX.p[0] < minX_) {
|
|
24
24
|
minX = bounds.minX;
|
|
25
25
|
minX_ = bounds.minX.p[0];
|
|
@@ -15,10 +15,10 @@ function areBoxesIntersecting(closed: boolean) {
|
|
|
15
15
|
let [[bx0, by0],[bx1, by1]] = b;
|
|
16
16
|
|
|
17
17
|
// Swap so smaller coordinate comes first
|
|
18
|
-
if (ay0 > ay1) { [ay0,ay1] = [ay1,ay0] }
|
|
19
|
-
if (by0 > by1) { [by0,by1] = [by1,by0] }
|
|
20
|
-
if (ax0 > ax1) { [ax0,ax1] = [ax1,ax0] }
|
|
21
|
-
if (bx0 > bx1) { [bx0,bx1] = [bx1,bx0] }
|
|
18
|
+
if (ay0 > ay1) { [ay0,ay1] = [ay1,ay0] }
|
|
19
|
+
if (by0 > by1) { [by0,by1] = [by1,by0] }
|
|
20
|
+
if (ax0 > ax1) { [ax0,ax1] = [ax1,ax0] }
|
|
21
|
+
if (bx0 > bx1) { [bx0,bx1] = [bx1,bx0] }
|
|
22
22
|
|
|
23
23
|
return closed
|
|
24
24
|
? (
|
|
@@ -32,8 +32,8 @@ function sweepLine<T>(
|
|
|
32
32
|
predicate: (item1: T, item2: T) => boolean): [T,T][] {
|
|
33
33
|
|
|
34
34
|
// Initialize event queue to contain all endpoints.
|
|
35
|
-
|
|
36
|
-
for (
|
|
35
|
+
const events: IEvent<T>[] = [];
|
|
36
|
+
for (const item of items) {
|
|
37
37
|
events.push({
|
|
38
38
|
type: EVENT_LEFT,
|
|
39
39
|
item,
|
|
@@ -48,15 +48,15 @@ function sweepLine<T>(
|
|
|
48
48
|
|
|
49
49
|
events.sort(compare);
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
const activeItems = new Set<T>();
|
|
52
52
|
|
|
53
53
|
/** A list of pairs of items that passed the predicate */
|
|
54
|
-
|
|
55
|
-
for (
|
|
56
|
-
|
|
54
|
+
const pairedItems: [T,T][] = [];
|
|
55
|
+
for (const event of events) {
|
|
56
|
+
const { item } = event;
|
|
57
57
|
|
|
58
58
|
if (event.type === EVENT_LEFT) {
|
|
59
|
-
for (
|
|
59
|
+
for (const activeItem of activeItems.values()) {
|
|
60
60
|
if (predicate(item, activeItem)) {
|
|
61
61
|
pairedItems.push([item, activeItem]);
|
|
62
62
|
}
|
|
@@ -93,7 +93,7 @@ interface IEvent<T> {
|
|
|
93
93
|
* @param b Another event
|
|
94
94
|
*/
|
|
95
95
|
function compare<T>(a: IEvent<T>, b: IEvent<T>) {
|
|
96
|
-
|
|
96
|
+
const res = a.x - b.x;
|
|
97
97
|
|
|
98
98
|
if (res !== 0) { return res; }
|
|
99
99
|
|
package/src/to-scale-axis.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
declare
|
|
1
|
+
/** @internal */
|
|
2
|
+
declare const _debug_: Debug;
|
|
3
3
|
|
|
4
4
|
import { length } from 'flo-bezier3';
|
|
5
5
|
import { Debug } from './debug/debug.js';
|
|
@@ -45,21 +45,22 @@ function toScaleAxis(
|
|
|
45
45
|
s: number,
|
|
46
46
|
f: (s: number) => (r: number) => number = linearScale): Mat {
|
|
47
47
|
|
|
48
|
+
let timingStart = 0;
|
|
48
49
|
if (typeof _debug_ !== 'undefined') {
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
timingStart = performance.now();
|
|
51
|
+
const leaves = getLeaves(mat.cpNode);
|
|
51
52
|
_debug_.generated.elems.leaves.push(leaves);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/** The largest vertex (as measured by its inscribed disk) */
|
|
55
|
-
|
|
56
|
+
const cpNodes: CpNode[] = [];
|
|
56
57
|
traverseVertices(
|
|
57
58
|
clone(mat.cpNode),
|
|
58
59
|
cpNode => { cpNodes.push(cpNode); }
|
|
59
60
|
);
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
const cpNode = getLargestVertex(cpNodes);
|
|
63
|
+
const f_ = f(s);
|
|
63
64
|
|
|
64
65
|
if (typeof _debug_ !== 'undefined') {
|
|
65
66
|
_debug_.generated.elems.maxVertex.push(cpNode);
|
|
@@ -69,22 +70,22 @@ function toScaleAxis(
|
|
|
69
70
|
* All vertices that are set to be culled initially. This may change later
|
|
70
71
|
* in order to preserve topology.
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
const culls: Set<Circle> = new Set();
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
const rMap: Map<CpNode,number> = new Map();
|
|
75
76
|
|
|
76
77
|
traverseEdges(cpNode, function(cpNode) {
|
|
77
78
|
/** The occulating radius stored with this vertex. */
|
|
78
|
-
|
|
79
|
+
const R = rMap.get(cpNode) || f_(cpNode.cp.circle.radius);
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
const cpNode_ = cpNode.next;
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
const l = length([0,1], getCurveToNext(cpNode));
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
const r = cpNode_.cp.circle.radius;
|
|
86
|
+
const r_ = f_(r);
|
|
86
87
|
if (R - l > r_) {
|
|
87
|
-
for (
|
|
88
|
+
for (const cpNode of cpNode_.getCpNodesOnCircle()) {
|
|
88
89
|
rMap.set(cpNode, R - l); // Update osculating radii
|
|
89
90
|
}
|
|
90
91
|
culls.add(cpNode_.cp.circle);
|
|
@@ -98,8 +99,8 @@ function toScaleAxis(
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
// TODO - put line below back - goes into infinite loop
|
|
101
|
-
//
|
|
102
|
-
|
|
102
|
+
//const sat: Mat = { cpNode, cpTrees: createNewCpTree(cpNode) };
|
|
103
|
+
const sat: Mat = { cpNode, cpTrees: undefined };
|
|
103
104
|
|
|
104
105
|
addDebugInfo(sat, timingStart);
|
|
105
106
|
|
package/src/traverse-edges.ts
CHANGED
|
@@ -14,10 +14,10 @@ function traverseEdges(
|
|
|
14
14
|
|
|
15
15
|
// Since the tree is unrooted we must iterate in all directions from the
|
|
16
16
|
// given vertex.
|
|
17
|
-
|
|
17
|
+
const cps = cpNode.getCpNodesOnCircle();
|
|
18
18
|
|
|
19
19
|
while (cps.length) {
|
|
20
|
-
|
|
20
|
+
const cp = cps.pop();
|
|
21
21
|
f(cp);
|
|
22
22
|
|
|
23
23
|
if (cp.isTerminating()) { continue; }
|
package/src/traverse-vertices.ts
CHANGED
package/webpack.config.cjs
CHANGED
|
@@ -3,11 +3,6 @@ const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
|
3
3
|
const ResolveTypeScriptPlugin = require("resolve-typescript-plugin");
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
////////////////////////////////
|
|
7
|
-
const library = 'FloMat';
|
|
8
|
-
////////////////////////////////
|
|
9
|
-
|
|
10
|
-
|
|
11
6
|
const extensions = [
|
|
12
7
|
'.js', '.mjs', '.cjs',
|
|
13
8
|
'.jsx', '.cjsx', '.mjsx'
|
|
@@ -15,8 +10,8 @@ const extensions = [
|
|
|
15
10
|
|
|
16
11
|
|
|
17
12
|
const config_Basic = {
|
|
18
|
-
|
|
19
|
-
mode: 'development',
|
|
13
|
+
mode: 'production',
|
|
14
|
+
// mode: 'development',
|
|
20
15
|
entry: './src/index.ts',
|
|
21
16
|
resolve: {
|
|
22
17
|
extensions,
|
|
@@ -49,40 +44,12 @@ const config_Basic = {
|
|
|
49
44
|
// set the current working directory for displaying module paths
|
|
50
45
|
cwd: process.cwd(),
|
|
51
46
|
})
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const lib = {
|
|
57
|
-
path: path.resolve(__dirname, 'browser'),
|
|
58
|
-
library,
|
|
59
|
-
libraryTarget: 'var'
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/** Global var library, minified */
|
|
64
|
-
const config_VarMinify = {
|
|
65
|
-
...config_Basic,
|
|
66
|
-
output: {
|
|
67
|
-
filename: 'index.min.js',
|
|
68
|
-
...lib
|
|
69
|
-
},
|
|
70
|
-
optimization: {
|
|
71
|
-
minimize: true
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
/** Global var library, not minified */
|
|
77
|
-
const config_VarNoMinify = {
|
|
78
|
-
...config_Basic,
|
|
47
|
+
],
|
|
79
48
|
output: {
|
|
80
|
-
|
|
81
|
-
|
|
49
|
+
path: path.resolve(__dirname, 'browser'),
|
|
50
|
+
library: { type: 'module' }
|
|
82
51
|
},
|
|
83
|
-
|
|
84
|
-
minimize: false
|
|
85
|
-
}
|
|
52
|
+
experiments: { outputModule: true }
|
|
86
53
|
}
|
|
87
54
|
|
|
88
55
|
|
|
@@ -90,18 +57,10 @@ const config_VarNoMinify = {
|
|
|
90
57
|
const config_EsmMinify = {
|
|
91
58
|
...config_Basic,
|
|
92
59
|
output: {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
library: {
|
|
96
|
-
type: 'module'
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
optimization: {
|
|
100
|
-
minimize: true
|
|
60
|
+
...config_Basic.output,
|
|
61
|
+
filename: 'index.min.js',
|
|
101
62
|
},
|
|
102
|
-
|
|
103
|
-
outputModule: true
|
|
104
|
-
}
|
|
63
|
+
optimization: { minimize: true }
|
|
105
64
|
};
|
|
106
65
|
|
|
107
66
|
|
|
@@ -109,24 +68,14 @@ const config_EsmMinify = {
|
|
|
109
68
|
const config_EsmNoMinify = {
|
|
110
69
|
...config_Basic,
|
|
111
70
|
output: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
library: {
|
|
115
|
-
type: 'module'
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
optimization: {
|
|
119
|
-
minimize: false
|
|
71
|
+
...config_Basic.output,
|
|
72
|
+
filename: 'index.js',
|
|
120
73
|
},
|
|
121
|
-
|
|
122
|
-
outputModule: true
|
|
123
|
-
}
|
|
74
|
+
optimization: { minimize: false },
|
|
124
75
|
};
|
|
125
76
|
|
|
126
77
|
|
|
127
78
|
module.exports = [
|
|
128
|
-
config_VarMinify,
|
|
129
|
-
config_VarNoMinify,
|
|
130
79
|
config_EsmMinify,
|
|
131
80
|
config_EsmNoMinify
|
|
132
81
|
];
|