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
|
@@ -2,13 +2,13 @@ import { CpNode } from "../cp-node.js";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
function* iterateAllOnLoop(cpNode: CpNode) {
|
|
5
|
-
|
|
5
|
+
yield cpNode;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
let cpNode_ = cpNode.next;
|
|
8
|
+
while (cpNode_ !== cpNode) {
|
|
9
|
+
yield cpNode_;
|
|
10
|
+
cpNode_ = cpNode_.next;
|
|
11
|
+
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
@@ -4,20 +4,20 @@ import { getChildren } from './get-children.js';
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
function traverseAllForward(
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
cpNode: CpNode,
|
|
8
|
+
traverseEdgesCallback: (cpNode: CpNode) => void) {
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// Since the tree is unrooted we must iterate in all directions from the
|
|
11
|
+
// given vertex.
|
|
12
|
+
const cps = [cpNode];
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
while (cps.length) {
|
|
15
|
+
const cp = cps.pop()!;
|
|
16
|
+
traverseEdgesCallback(cp);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (isTerminating(cp)) { continue; }
|
|
19
|
+
cps.push(...getChildren(cp));
|
|
20
|
+
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
|
|
@@ -2,25 +2,27 @@ import { CpNode } from "../cp-node.js";
|
|
|
2
2
|
import { isTerminating } from "./is-terminating.js";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
function traverseCp(
|
|
6
|
-
|
|
5
|
+
function traverseCp(
|
|
6
|
+
cpStart: CpNode) {
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
return [cpNode]; // one-sharp corner
|
|
10
|
-
}
|
|
8
|
+
let cpNode = cpStart;
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
if (isTerminating(cpNode)) {
|
|
11
|
+
return [cpNode]; // one-sharp corner
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const visitedCps: CpNode[] = [];
|
|
15
|
+
do {
|
|
16
|
+
visitedCps.push(cpNode);
|
|
17
|
+
|
|
18
|
+
const next = cpNode.next.prevOnCircle;
|
|
19
|
+
cpNode = cpNode === next
|
|
20
|
+
? cpNode = cpNode.next.next // Terminal vertex
|
|
21
|
+
: cpNode = next // Take last exit
|
|
22
|
+
|
|
23
|
+
} while (cpNode !== cpStart);
|
|
24
|
+
|
|
25
|
+
return visitedCps;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
|
|
@@ -4,18 +4,18 @@ import { getAllOnLoop } from './get-all-on-loop.js';
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
function traverseEdges(
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
cpNode: CpNode,
|
|
8
|
+
traverseEdgesCallback: (cpNode: CpNode) => void) {
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const cpNodes = getAllOnLoop(cpNode);
|
|
11
|
+
const seen = new Set<CpNode>();
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
for (cpNode of cpNodes) {
|
|
14
|
+
if (!isTerminating(cpNode) && !seen.has(cpNode.next.prevOnCircle)) {
|
|
15
|
+
traverseEdgesCallback(cpNode);
|
|
16
|
+
}
|
|
17
|
+
seen.add(cpNode);
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
|
|
@@ -6,26 +6,26 @@ import { getVertexForwardChildren } from './get-vertex-forward-children.js';
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
function traverseVertices(
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
cpStart: CpNode,
|
|
10
|
+
traverseVerticesCallback: (cpNode: CpNode) => void) {
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
traverseVerticesCallback(cpStart);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
// Since the tree is unrooted we must iterate in all directions from the
|
|
15
|
+
// given cpNode.
|
|
16
|
+
const cpNodes =
|
|
17
|
+
getAllOnCircle(cpStart)
|
|
18
|
+
.filter(cpNode => !isTerminating(cpNode))
|
|
19
|
+
.map(cpNode => cpNode.next);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
for (const cpNode of cpNodes) {
|
|
22
|
+
const cps = [cpNode];
|
|
23
|
+
while (cps.length) {
|
|
24
|
+
const cp = cps.pop()!;
|
|
25
|
+
traverseVerticesCallback(cp);
|
|
26
|
+
cps.push(...getVertexForwardChildren(cp));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
|
package/src/curve/curve.ts
CHANGED
|
@@ -5,32 +5,32 @@ import { Loop } from 'flo-boolean';
|
|
|
5
5
|
* Represents a bezier curve on the shape boundary / loop.
|
|
6
6
|
*/
|
|
7
7
|
interface Curve {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The closed loop of bezier curves representing the shape
|
|
10
|
+
* boundary this curve belongs to.
|
|
11
|
+
*/
|
|
12
|
+
loop: Loop;
|
|
13
|
+
/**
|
|
14
|
+
* The bezier control points.
|
|
15
|
+
*/
|
|
16
|
+
ps: number[][];
|
|
17
|
+
/**
|
|
18
|
+
* The previous curve (when going in a negative direction around
|
|
19
|
+
* the shape boundary, i.e. clockwise for the outer shape and anti-clockwise
|
|
20
|
+
* for the holes (if any))
|
|
21
|
+
*/
|
|
22
|
+
prev: Curve;
|
|
23
|
+
/**
|
|
24
|
+
* The next curve (when going in a positive direction around
|
|
25
|
+
* the shape boundary, i.e. anti-clockwise for the outer shape and clockwise
|
|
26
|
+
* for the holes (if any))
|
|
27
|
+
*/
|
|
28
|
+
next: Curve;
|
|
29
|
+
/**
|
|
30
|
+
* The curve's ordered index in the loop. This imposes a cycling
|
|
31
|
+
* ordering of the curves in the loop
|
|
32
|
+
*/
|
|
33
|
+
idx: number;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
|
|
@@ -2,7 +2,7 @@ import { Circle } from '../../../geometry/circle.js';
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
/** @internal */
|
|
5
|
-
function culls(g: SVGGElement, culls: Circle[]) {
|
|
5
|
+
function culls(g: SVGGElement, culls: Circle[]) {
|
|
6
6
|
const $elems: SVGElement[] = [];
|
|
7
7
|
|
|
8
8
|
for (const circle of culls) {
|
|
@@ -11,7 +11,7 @@ function culls(g: SVGGElement, culls: Circle[]) {
|
|
|
11
11
|
$elems.push(drawCircle(g, p, 0.4, 'cyan thin5 nofill'));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
return $elems;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
|
@@ -7,41 +7,41 @@ import { CpNodeFs } from '../../../cp-node/cp-node-fs.js';
|
|
|
7
7
|
|
|
8
8
|
/** @internal */
|
|
9
9
|
function drawCpNode(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
g: SVGGElement,
|
|
11
|
+
cpNode: CpNode,
|
|
12
|
+
classes = 'blue thin2 nofill',
|
|
13
|
+
delay = 0,
|
|
14
|
+
scaleFactor = 1) {
|
|
15
|
+
|
|
16
|
+
const circle = scaleCircle(
|
|
17
|
+
cpNode.cp.circle,
|
|
18
|
+
1
|
|
19
|
+
);
|
|
20
|
+
const { center: c, radius: r } = circle;
|
|
21
|
+
|
|
22
|
+
const poss = CpNodeFs.getAllOnCircle(cpNode)
|
|
23
23
|
.map(cpNode => cpNode.cp.pointOnShape)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const { dot, circle: drawCircle, crossHair } = drawFs;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const $circle = drawCircle(g, circle, classes, delay);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const $cps: SVGElement[] = [];
|
|
30
|
+
const $ls: SVGElement[] = [];
|
|
31
|
+
for (let i=0; i<poss.length; i++) {
|
|
32
|
+
const p = poss[i].p;
|
|
33
|
+
$cps.push(...dot(g, p, 0.01*(i+1)*scaleFactor, 'blue', delay));
|
|
34
|
+
$ls.push(...drawFs.line(g, [p, c], 'thin5 red', delay));
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
37
|
+
const $cross = crossHair(g, c, 'orange thin10 nofill', 2*scaleFactor, delay);
|
|
38
|
+
|
|
39
|
+
// if (r === 0) {
|
|
40
|
+
// const $cross = crossHair(g, circle.center, 'red thin2 nofill', 0.02*scaleFactor, delay);
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
return [...$cps, ...$ls, ...$circle, ...$cross] as SVGElement[];
|
|
44
|
+
}
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
export { drawCpNode }
|
|
@@ -6,7 +6,7 @@ function drawCull(
|
|
|
6
6
|
cull: number[],
|
|
7
7
|
classes = 'thin10 cyan nofill',
|
|
8
8
|
delay = 0,
|
|
9
|
-
scaleFactor = 1) {
|
|
9
|
+
scaleFactor = 1) {
|
|
10
10
|
|
|
11
11
|
const $elems: SVGElement[] = [];
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ function drawCull(
|
|
|
14
14
|
g, cull, classes, 0.1*scaleFactor, delay)
|
|
15
15
|
)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
return $elems;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
|
|
@@ -4,17 +4,17 @@ import { Curve } from '../../../curve/curve.js';
|
|
|
4
4
|
|
|
5
5
|
/** @internal */
|
|
6
6
|
function dullCorner(
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
g: SVGGElement,
|
|
8
|
+
curve: Curve,
|
|
9
9
|
classes = 'orange',
|
|
10
10
|
delay = 0,
|
|
11
11
|
scaleFactor = 1) {
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const ps = curve.ps;
|
|
14
|
+
const p = curve.ps[ps.length-1];
|
|
15
|
+
const $pos = drawFs.dot(g, p, 0.1*0.5*scaleFactor, classes, delay);
|
|
16
|
+
|
|
17
|
+
return $pos;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
|
|
@@ -22,12 +22,12 @@ import { drawSpeed } from './draw-speed.js';
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
type DrawElemFunction<T extends DebugElemKey> = (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
g: SVGGElement,
|
|
26
|
+
elem: DebugElem[T],
|
|
27
|
+
classes?: string,
|
|
28
|
+
delay?: number,
|
|
29
|
+
scaleFactor?: number,
|
|
30
|
+
options?: any) => SVGElement[];
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
/** @internal */
|
|
@@ -36,32 +36,32 @@ type DrawElemFunctions = { [T in DebugElemKey]: DrawElemFunction<T> }
|
|
|
36
36
|
|
|
37
37
|
/** @internal */
|
|
38
38
|
const drawElemFs: DrawElemFunctions = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
oneProng: drawOneProng,
|
|
40
|
+
// oneProngAtDullCorner,
|
|
41
|
+
// csf,
|
|
42
|
+
twoProng: drawTwoProng(false, true),
|
|
43
|
+
threeProng: drawThreeProng,
|
|
44
|
+
boundingHull,
|
|
45
|
+
looseBoundingBox,
|
|
46
|
+
tightBoundingBox,
|
|
47
|
+
// sharpCorner,
|
|
48
|
+
// dullCorner,
|
|
49
|
+
vertex,
|
|
50
|
+
mat: drawMat,
|
|
51
|
+
// sat: drawMat('sat'),
|
|
52
|
+
maxVertex,
|
|
53
|
+
leaves: drawLeaves,
|
|
54
|
+
cull: drawCull,
|
|
55
|
+
cpNode: drawCpNode,
|
|
56
|
+
branch: drawBranch,
|
|
57
|
+
holeCloser: drawTwoProng(false, false),
|
|
58
|
+
speed: drawSpeed
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
const drawElemFsDetailed: DrawElemFunctions = {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
...drawElemFs,
|
|
64
|
+
twoProng: drawTwoProng(true, true),
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
|
|
@@ -10,7 +10,7 @@ function drawLeaves(
|
|
|
10
10
|
leaves: CpNode[],
|
|
11
11
|
classes = 'thin10 deeppink nofill',
|
|
12
12
|
delay = 0,
|
|
13
|
-
scaleFactor = 1) {
|
|
13
|
+
scaleFactor = 1) {
|
|
14
14
|
|
|
15
15
|
const $elems: SVGElement[] = [];
|
|
16
16
|
const { line, dot, circle: drawCircle } = drawFs;
|
|
@@ -32,19 +32,19 @@ function drawLeaves(
|
|
|
32
32
|
$cps.push(...dot(g, p, 0.01*(i+1)*scaleFactor, 'pinker', delay));
|
|
33
33
|
$ls.push(...line(g, [p, c], 'thin5 red', delay));
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
|
|
36
|
+
const $circle = drawCircle(g, circle, classes, delay);
|
|
37
|
+
// const $cp = dot(g, p, 0.005*scaleFactor, 'pinker', delay);
|
|
38
|
+
|
|
39
|
+
$elems.push(...[
|
|
40
|
+
...$circle,
|
|
41
|
+
...$cps,
|
|
42
|
+
...$ls,
|
|
43
|
+
...$center
|
|
44
|
+
]);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
return $elems;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
|
|
@@ -3,18 +3,18 @@ import { drawFs } from "flo-draw";
|
|
|
3
3
|
|
|
4
4
|
/** @internal */
|
|
5
5
|
function looseBoundingBox(
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
g: SVGGElement,
|
|
7
|
+
box: number[][],
|
|
8
8
|
classes = 'thin5 brown nofill',
|
|
9
9
|
delay = 0,
|
|
10
10
|
scaleFactor = 1) {
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const [[x0, y0],[x1, y1]] = box;
|
|
13
|
+
box = [[x0, y0],[x1, y0],[x1,y1],[x0,y1]];
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const $box = drawFs.polygon(g, box, classes, delay);
|
|
16
|
+
|
|
17
|
+
return $box;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
|
|
@@ -3,12 +3,12 @@ import { CpNode } from '../../../cp-node/cp-node.js';
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
/** @internal */
|
|
6
|
-
function maxVertex(g: SVGGElement, cpNode: CpNode) {
|
|
6
|
+
function maxVertex(g: SVGGElement, cpNode: CpNode) {
|
|
7
7
|
const circle = cpNode.cp.circle;
|
|
8
8
|
|
|
9
9
|
const $elems = drawFs.circle(g, circle, 'brown thin10 nofill');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
return $elems;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
@@ -19,7 +19,7 @@ function oneProngAtDullCorner(
|
|
|
19
19
|
const $circle = drawFs.dot(g, oCircle.center, 0.25, 'orange');
|
|
20
20
|
const $pos = drawFs.circle(g, oCircle, 'orange thin10 nofill');
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
return [...$center, ...$circle, ...$pos];
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
|
|
@@ -16,7 +16,7 @@ function drawOneProng(
|
|
|
16
16
|
const $circle = drawFs.dot(g, circle.center, 0.05*scaleFactor, 'deeppink', delay);
|
|
17
17
|
const $pos = drawFs.circle(g, circle, 'deeppink thin5 nofill', delay);
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
return [...$center, ...$circle, ...$pos];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
|
|
@@ -4,16 +4,16 @@ import { Curve } from '../../../curve/curve.js';
|
|
|
4
4
|
|
|
5
5
|
/** @internal */
|
|
6
6
|
function sharpCorner(
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
g: SVGGElement,
|
|
8
|
+
curve: Curve,
|
|
9
9
|
classes = 'green',
|
|
10
10
|
delay = 0,
|
|
11
11
|
scaleFactor = 1) {
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const p = curve.ps[curve.ps.length-1];
|
|
14
|
+
const $pos = drawFs.dot(g, p, 0.6*scaleFactor, 'green', delay);
|
|
15
|
+
|
|
16
|
+
return $pos;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
|
|
@@ -11,7 +11,7 @@ function drawSpeed(
|
|
|
11
11
|
cpNode: CpNode,
|
|
12
12
|
classes_?: string,
|
|
13
13
|
delay = 0,
|
|
14
|
-
scaleFactor = 1) {
|
|
14
|
+
scaleFactor = 1) {
|
|
15
15
|
|
|
16
16
|
const $elems: SVGElement[] = [];
|
|
17
17
|
|
|
@@ -28,7 +28,7 @@ function drawSpeed(
|
|
|
28
28
|
const n = toLength(normal(ps,t), ss);
|
|
29
29
|
$elems.push(...drawFs.line(g, [p,translate(p,n)], 'red thin5', delay));
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
return $elems;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
|