flo-mat 2.0.3 → 2.0.4
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/browser/index.js +223 -173
- package/browser/index.min.js +1 -1
- package/package.json +14 -14
package/browser/index.js
CHANGED
|
@@ -24,32 +24,32 @@ var __webpack_exports__ = {};
|
|
|
24
24
|
|
|
25
25
|
// EXPORTS
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
M1: () => (/* reexport */ CpNode),
|
|
28
|
+
bt: () => (/* reexport */ PointOnShape),
|
|
29
|
+
A3: () => (/* reexport */ beziersToSvgPathStr),
|
|
30
|
+
zh: () => (/* reexport */ drawBranch),
|
|
31
|
+
Ls: () => (/* reexport */ drawElemFunctions),
|
|
32
|
+
CU: () => (/* reexport */ drawMat),
|
|
33
|
+
gM: () => (/* reexport */ enableDebugForMat),
|
|
34
|
+
SQ: () => (/* reexport */ findMats),
|
|
35
|
+
BG: () => (/* reexport */ getBoundaryBezierPartsToNext),
|
|
36
|
+
Ij: () => (/* reexport */ getBoundaryBeziersToNext),
|
|
37
|
+
tQ: () => (/* reexport */ getBoundaryPieceBeziers),
|
|
38
|
+
C_: () => (/* reexport */ getBranches),
|
|
39
|
+
aS: () => (/* reexport */ getClosestBoundaryPoint),
|
|
40
|
+
DZ: () => (/* reexport */ getClosestSquareDistanceToRect),
|
|
41
|
+
wH: () => (/* reexport */ getCurveBetween),
|
|
42
|
+
N0: () => (/* reexport */ getCurveToNext),
|
|
43
|
+
Jt: () => (/* reexport */ getPathsFromStr),
|
|
44
|
+
tO: () => (/* reexport */ getShapeBounds),
|
|
45
|
+
bQ: () => (/* reexport */ loop_loopFromBeziers),
|
|
46
|
+
UW: () => (/* reexport */ simplifyMat),
|
|
47
|
+
_T: () => (/* reexport */ simplifyMatMapOnly),
|
|
48
|
+
Dw: () => (/* reexport */ sweep_line_sweepLine),
|
|
49
|
+
xs: () => (/* reexport */ toScaleAxis),
|
|
50
|
+
y9: () => (/* reexport */ traverseEdges),
|
|
51
|
+
Fw: () => (/* reexport */ traverseVertices),
|
|
52
|
+
QE: () => (/* reexport */ trimMat)
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
;// CONCATENATED MODULE: ./node_modules/flo-boolean/node/svg/beziers-to-svg-path-str.js
|
|
@@ -937,52 +937,33 @@ function dot(a, b) {
|
|
|
937
937
|
}
|
|
938
938
|
|
|
939
939
|
//# sourceMappingURL=dot.js.map
|
|
940
|
-
;// CONCATENATED MODULE: ./node_modules/flo-memoize/node/
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
*
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
function memoize2(f) {
|
|
968
|
-
if (!SUPPORTED) {
|
|
969
|
-
return f;
|
|
970
|
-
}
|
|
971
|
-
const results = new WeakMap();
|
|
972
|
-
return function (a, b) {
|
|
973
|
-
let result = pairMap_get(results, a, b);
|
|
974
|
-
if (result !== undefined) {
|
|
975
|
-
//console.log('cache hit');
|
|
976
|
-
return result;
|
|
977
|
-
}
|
|
978
|
-
//console.log('cache miss');
|
|
979
|
-
result = f(a, b);
|
|
980
|
-
pairMap_set(results, a, b, result);
|
|
981
|
-
return result;
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
//# sourceMappingURL=index.js.map
|
|
940
|
+
;// CONCATENATED MODULE: ./node_modules/flo-memoize/node/memoize.js
|
|
941
|
+
/**
|
|
942
|
+
* Memoize (by reference on the input parameter) the given arity 1 function.
|
|
943
|
+
*
|
|
944
|
+
* * the input parameter must be an `object` (so it can be used as a key to
|
|
945
|
+
* `WeakMap` and thus garbage collected later; this is especially important
|
|
946
|
+
* in functional programming where a lot of garbage collection takes place;
|
|
947
|
+
*
|
|
948
|
+
* * use `memoizePrimitive` instead if it is not important that the keys
|
|
949
|
+
* will *never* be garbage collected
|
|
950
|
+
*/
|
|
951
|
+
function memoize(f) {
|
|
952
|
+
const results = new WeakMap();
|
|
953
|
+
return function (t) {
|
|
954
|
+
let r = results.get(t);
|
|
955
|
+
if (r !== undefined) {
|
|
956
|
+
//console.log('cache hit');
|
|
957
|
+
return r;
|
|
958
|
+
}
|
|
959
|
+
//console.log('cache miss');
|
|
960
|
+
r = f(t);
|
|
961
|
+
results.set(t, r);
|
|
962
|
+
return r;
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
//# sourceMappingURL=memoize.js.map
|
|
986
967
|
;// CONCATENATED MODULE: ./node_modules/flo-bezier3/node/local-properties-at-t/evaluate/double/eval-de-casteljau.js
|
|
987
968
|
/**
|
|
988
969
|
* Returns the resulting point of evaluating the given bezier curve at the
|
|
@@ -9840,6 +9821,7 @@ function completeLoop(expMax, takenOuts, out) {
|
|
|
9840
9821
|
// Move immediately to the outgoing start of the loop
|
|
9841
9822
|
let out_ = out;
|
|
9842
9823
|
let additionalBezier;
|
|
9824
|
+
// console.log(out_);
|
|
9843
9825
|
do {
|
|
9844
9826
|
takenOuts.add(out_); // Mark this intersection as taken
|
|
9845
9827
|
const { beziers: additionalBeziers, in_, inBez } = getBeziersToNextContainer(expMax, out_);
|
|
@@ -10939,43 +10921,53 @@ function getLoopsFromTree(root) {
|
|
|
10939
10921
|
}
|
|
10940
10922
|
|
|
10941
10923
|
//# sourceMappingURL=get-loops-from-tree.js.map
|
|
10942
|
-
;// CONCATENATED MODULE: ./node_modules/flo-
|
|
10943
|
-
/**
|
|
10944
|
-
* Returns `true` if the 2 given axis-aligned rectangular boxes intersect.
|
|
10945
|
-
*
|
|
10946
|
-
* * **exact**: not susceptible to floating point round-off
|
|
10947
|
-
*
|
|
10948
|
-
* @param closed if `true`, interpret boxes as being closed (i.e. they contain
|
|
10949
|
-
* their border), otherwise open.
|
|
10950
|
-
* @param a an axis-aligned rectangular box (given by an array of two points,
|
|
10951
|
-
* e.g. `[[1,2], [3,4]]`)
|
|
10952
|
-
* @param b another axis-aligned rectangular box
|
|
10953
|
-
*
|
|
10954
|
-
* @doc mdx
|
|
10955
|
-
*/
|
|
10956
|
-
function areBoxesIntersecting(closed, a, b) {
|
|
10957
|
-
let [[ax0, ay0], [ax1, ay1]] = a;
|
|
10958
|
-
let [[bx0, by0], [bx1, by1]] = b;
|
|
10959
|
-
// Swap so smaller coordinate comes first
|
|
10960
|
-
if (ay0 > ay1) {
|
|
10961
|
-
[ay0, ay1] = [ay1, ay0];
|
|
10962
|
-
}
|
|
10963
|
-
if (by0 > by1) {
|
|
10964
|
-
[by0, by1] = [by1, by0];
|
|
10965
|
-
}
|
|
10966
|
-
if (ax0 > ax1) {
|
|
10967
|
-
[ax0, ax1] = [ax1, ax0];
|
|
10968
|
-
}
|
|
10969
|
-
if (bx0 > bx1) {
|
|
10970
|
-
[bx0, bx1] = [bx1, bx0];
|
|
10971
|
-
}
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10924
|
+
;// CONCATENATED MODULE: ./node_modules/flo-boolean/node/are-boxes-intersecting.js
|
|
10925
|
+
/**
|
|
10926
|
+
* Returns `true` if the 2 given axis-aligned rectangular boxes intersect.
|
|
10927
|
+
*
|
|
10928
|
+
* * **exact**: not susceptible to floating point round-off
|
|
10929
|
+
*
|
|
10930
|
+
* @param closed if `true`, interpret boxes as being closed (i.e. they contain
|
|
10931
|
+
* their border), otherwise open.
|
|
10932
|
+
* @param a an axis-aligned rectangular box (given by an array of two points,
|
|
10933
|
+
* e.g. `[[1,2], [3,4]]`)
|
|
10934
|
+
* @param b another axis-aligned rectangular box
|
|
10935
|
+
*
|
|
10936
|
+
* @doc mdx
|
|
10937
|
+
*/
|
|
10938
|
+
function areBoxesIntersecting(closed, a, b) {
|
|
10939
|
+
let [[ax0, ay0], [ax1, ay1]] = a;
|
|
10940
|
+
let [[bx0, by0], [bx1, by1]] = b;
|
|
10941
|
+
// Swap so smaller coordinate comes first
|
|
10942
|
+
if (ay0 > ay1) {
|
|
10943
|
+
[ay0, ay1] = [ay1, ay0];
|
|
10944
|
+
}
|
|
10945
|
+
if (by0 > by1) {
|
|
10946
|
+
[by0, by1] = [by1, by0];
|
|
10947
|
+
}
|
|
10948
|
+
if (ax0 > ax1) {
|
|
10949
|
+
[ax0, ax1] = [ax1, ax0];
|
|
10950
|
+
}
|
|
10951
|
+
if (bx0 > bx1) {
|
|
10952
|
+
[bx0, bx1] = [bx1, bx0];
|
|
10953
|
+
}
|
|
10954
|
+
const closedX = closed || (ax0 === ax1 && bx0 === bx1);
|
|
10955
|
+
const closedY = closed || (ay0 === ay1 && by0 === by1);
|
|
10956
|
+
return ((closedX ? ax0 <= bx1 : ax0 < bx1) &&
|
|
10957
|
+
(closedX ? ax1 >= bx0 : ax1 > bx0) &&
|
|
10958
|
+
(closedY ? by0 <= ay1 : by0 < ay1) &&
|
|
10959
|
+
(closedY ? by1 >= ay0 : by1 > ay0));
|
|
10960
|
+
// return closed
|
|
10961
|
+
// ? ax0 <= bx1 &&
|
|
10962
|
+
// ax1 >= bx0 &&
|
|
10963
|
+
// by0 <= ay1 &&
|
|
10964
|
+
// by1 >= ay0
|
|
10965
|
+
// : ax0 < bx1 &&
|
|
10966
|
+
// ax1 > bx0 &&
|
|
10967
|
+
// by0 < ay1 &&
|
|
10968
|
+
// by1 > ay0
|
|
10969
|
+
}
|
|
10970
|
+
|
|
10979
10971
|
//# sourceMappingURL=are-boxes-intersecting.js.map
|
|
10980
10972
|
;// CONCATENATED MODULE: ./node_modules/flo-boolean/node/calc-containers/are-containers-intersecting.js
|
|
10981
10973
|
|
|
@@ -18324,6 +18316,9 @@ function boxExpToBox(boxExp) {
|
|
|
18324
18316
|
function getInOutsViaSides(container, ioIdx) {
|
|
18325
18317
|
// We check one __X__ for each curve with an intersection within this container
|
|
18326
18318
|
const xs_ = container.xs;
|
|
18319
|
+
//if (xs_.length === 4) {
|
|
18320
|
+
// console.log(xs_.map(x => x.x.kind))
|
|
18321
|
+
//}
|
|
18327
18322
|
const inOuts = [];
|
|
18328
18323
|
// get a map from each Curve to each __X__ of this container
|
|
18329
18324
|
const xMap = new Map();
|
|
@@ -18496,6 +18491,7 @@ function getInOutsViaCrossing(container, ioIdx) {
|
|
|
18496
18491
|
function getContainerInOuts(container, ioIdx) {
|
|
18497
18492
|
// We check one __X__ for each curve with an intersection within this container
|
|
18498
18493
|
const xs = container.xs;
|
|
18494
|
+
// console.log(xs);
|
|
18499
18495
|
// Check nature of Xs. If Xs is the very common case where two curves cross
|
|
18500
18496
|
// we can use a faster check. Also in the bit less common case where all
|
|
18501
18497
|
// curves are joining at an interface we can do a fast ccw (the ccw part
|
|
@@ -20828,6 +20824,7 @@ function makeSimpleX(t, curve, kind) {
|
|
|
20828
20824
|
|
|
20829
20825
|
|
|
20830
20826
|
|
|
20827
|
+
|
|
20831
20828
|
/**
|
|
20832
20829
|
* Returns the pairs of intersection `t` values between the curves. Interface
|
|
20833
20830
|
* intersections may not be returned - they should already be caught.
|
|
@@ -20846,7 +20843,9 @@ function getCurvesIntersections(expMax) {
|
|
|
20846
20843
|
// curves are connected at endpoints
|
|
20847
20844
|
// closed bounding boxes are guaranteed to intersect - don't check
|
|
20848
20845
|
// check open bounding boxes
|
|
20849
|
-
const aabbsIntersectOpen = areBoxesIntersecting(false,
|
|
20846
|
+
const aabbsIntersectOpen = areBoxesIntersecting(false,
|
|
20847
|
+
// const aabbsIntersectOpen = areBoxesIntersecting(true,
|
|
20848
|
+
getBoundingBox_(psA), getBoundingBox_(psB));
|
|
20850
20849
|
if (!aabbsIntersectOpen) {
|
|
20851
20850
|
return checkEndpoints(curveA, curveB);
|
|
20852
20851
|
}
|
|
@@ -20924,15 +20923,18 @@ function getLineLineIntersections(curveA, curveB, expMax) {
|
|
|
20924
20923
|
let psB = curveB.ps;
|
|
20925
20924
|
const bbA = getBoundingBox_(psA);
|
|
20926
20925
|
const bbB = getBoundingBox_(psB);
|
|
20926
|
+
// if (equal(psA,[[4,8],[4,7]]) && equal(psB,[[4,6],[4,8]])) {
|
|
20927
|
+
// console.log('testing');
|
|
20928
|
+
// }
|
|
20927
20929
|
if (curveA.next !== curveB && curveB.next !== curveA) {
|
|
20928
|
-
// the two
|
|
20930
|
+
// the two line curves are not consecutive in the loop
|
|
20929
20931
|
if (areBoxesIntersecting(true, bbA, bbB)) {
|
|
20930
20932
|
const xs = getIntersection(curveA, curveB, expMax, false);
|
|
20931
20933
|
return xs.length ? xs : undefined;
|
|
20932
20934
|
}
|
|
20933
20935
|
return undefined;
|
|
20934
20936
|
}
|
|
20935
|
-
// the two
|
|
20937
|
+
// the two line curves are consecutive in the loop
|
|
20936
20938
|
const swap = curveB.next === curveA;
|
|
20937
20939
|
if (swap) {
|
|
20938
20940
|
[curveA, curveB] = [curveB, curveA];
|
|
@@ -20952,16 +20954,14 @@ function getLineLineIntersections(curveA, curveB, expMax) {
|
|
|
20952
20954
|
}
|
|
20953
20955
|
// it is a line going back on itself
|
|
20954
20956
|
// - return endpoint intersections
|
|
20955
|
-
const
|
|
20956
|
-
const
|
|
20957
|
+
const lenCurveA = squared_distance_between_squaredDistanceBetween(psA[0], psA[1]);
|
|
20958
|
+
const lenCurveB = squared_distance_between_squaredDistanceBetween(psB[0], psB[1]);
|
|
20957
20959
|
let tPair;
|
|
20958
|
-
if (
|
|
20959
|
-
// tPair = [inversion01Precise(psA, psB[1]), 1];
|
|
20960
|
+
if (lenCurveA > lenCurveB) {
|
|
20960
20961
|
const t0 = mid(closestPointOnBezierCertified(psA, psB[1])[0].ri);
|
|
20961
20962
|
tPair = [t0, 1];
|
|
20962
20963
|
}
|
|
20963
20964
|
else {
|
|
20964
|
-
// tPair = [0, inversion01Precise(psB, psA[0])];
|
|
20965
20965
|
const t1 = mid(closestPointOnBezierCertified(psB, psA[0])[0].ri);
|
|
20966
20966
|
tPair = [0, t1];
|
|
20967
20967
|
}
|
|
@@ -21799,6 +21799,35 @@ function compareOrderedInOut(inOutA, inOutB) {
|
|
|
21799
21799
|
}
|
|
21800
21800
|
|
|
21801
21801
|
//# sourceMappingURL=compare-in-out.js.map
|
|
21802
|
+
;// CONCATENATED MODULE: ./node_modules/flo-boolean/node/calc-containers/filter-containers.js
|
|
21803
|
+
/**
|
|
21804
|
+
* Returns the containers that is the given containers filtered so that those
|
|
21805
|
+
* having only interface intersections or only a single (given as a pair) even
|
|
21806
|
+
* multiple intersection are not included.
|
|
21807
|
+
* @param containers
|
|
21808
|
+
*/
|
|
21809
|
+
function filterContainers(containers) {
|
|
21810
|
+
const containers_ = containers.filter(container => {
|
|
21811
|
+
const xs = container.xs;
|
|
21812
|
+
if (container.xs.length === 2) {
|
|
21813
|
+
const _x_ = xs[0];
|
|
21814
|
+
if (_x_.x.kind === 1 && _x_.x.ri.multiplicity % 2 === 0) {
|
|
21815
|
+
// multiple even intersection - exclude
|
|
21816
|
+
return false;
|
|
21817
|
+
}
|
|
21818
|
+
}
|
|
21819
|
+
for (const x of container.xs) {
|
|
21820
|
+
if (x.x.kind !== 4) {
|
|
21821
|
+
// include container if any __X__ is not an interface
|
|
21822
|
+
return true;
|
|
21823
|
+
}
|
|
21824
|
+
}
|
|
21825
|
+
return false; // exclude container
|
|
21826
|
+
});
|
|
21827
|
+
return containers_;
|
|
21828
|
+
}
|
|
21829
|
+
|
|
21830
|
+
//# sourceMappingURL=filter-containers.js.map
|
|
21802
21831
|
;// CONCATENATED MODULE: ./node_modules/flo-boolean/node/calc-containers/get-containers.js
|
|
21803
21832
|
|
|
21804
21833
|
|
|
@@ -21813,6 +21842,7 @@ function compareOrderedInOut(inOutA, inOutB) {
|
|
|
21813
21842
|
|
|
21814
21843
|
|
|
21815
21844
|
|
|
21845
|
+
|
|
21816
21846
|
/**
|
|
21817
21847
|
*
|
|
21818
21848
|
* @param containerDim
|
|
@@ -21826,10 +21856,10 @@ function getContainers(loops, containerDim, expMax) {
|
|
|
21826
21856
|
const xs3 = getInterfaceIntersections(loops);
|
|
21827
21857
|
const { extremes, xs: xs4 } = getExtremes(loops);
|
|
21828
21858
|
let xPairs = [...xs1, ...xs2, ...xs3, ...xs4];
|
|
21829
|
-
//console.log('general ', xs1);
|
|
21830
|
-
//console.log('self ', xs2);
|
|
21831
|
-
//console.log('interface', xs3);
|
|
21832
|
-
//console.log('topmost ', xs4);
|
|
21859
|
+
// console.log('general ', xs1);
|
|
21860
|
+
// console.log('self ', xs2);
|
|
21861
|
+
// console.log('interface', xs3);
|
|
21862
|
+
// console.log('topmost ', xs4);
|
|
21833
21863
|
if (typeof _debug_ !== 'undefined') {
|
|
21834
21864
|
for (const xPair of xs1) {
|
|
21835
21865
|
_debug_.generated.elems.intersection.push(...xPair);
|
|
@@ -21927,32 +21957,6 @@ function getContainers(loops, containerDim, expMax) {
|
|
|
21927
21957
|
}
|
|
21928
21958
|
return { extremes, containers };
|
|
21929
21959
|
}
|
|
21930
|
-
/**
|
|
21931
|
-
* Returns the containers that is the given containers filtered so that those
|
|
21932
|
-
* having only interface intersections or only a single (given as a pair) even
|
|
21933
|
-
* multiple intersection are not included.
|
|
21934
|
-
* @param containers
|
|
21935
|
-
*/
|
|
21936
|
-
function filterContainers(containers) {
|
|
21937
|
-
const containers_ = containers.filter(container => {
|
|
21938
|
-
const xs = container.xs;
|
|
21939
|
-
if (container.xs.length === 2) {
|
|
21940
|
-
const _x_ = xs[0];
|
|
21941
|
-
if (_x_.x.kind === 1 && _x_.x.ri.multiplicity % 2 === 0) {
|
|
21942
|
-
// multiple even intersection - exclude
|
|
21943
|
-
return false;
|
|
21944
|
-
}
|
|
21945
|
-
}
|
|
21946
|
-
for (const x of container.xs) {
|
|
21947
|
-
if (x.x.kind !== 4) {
|
|
21948
|
-
// include container if any __X__ is not an interface
|
|
21949
|
-
return true;
|
|
21950
|
-
}
|
|
21951
|
-
}
|
|
21952
|
-
return false; // exclude container
|
|
21953
|
-
});
|
|
21954
|
-
return containers_;
|
|
21955
|
-
}
|
|
21956
21960
|
function getLeftMost(container) {
|
|
21957
21961
|
return container.box[0][0];
|
|
21958
21962
|
}
|
|
@@ -22227,6 +22231,33 @@ function toLength(p, length) {
|
|
|
22227
22231
|
}
|
|
22228
22232
|
|
|
22229
22233
|
//# sourceMappingURL=to-length.js.map
|
|
22234
|
+
;// CONCATENATED MODULE: ./node_modules/flo-bezier3/node/simultaneous-properties/equal.js
|
|
22235
|
+
/**
|
|
22236
|
+
* Returns `true` if the two given bezier curves are exactly equal when compared
|
|
22237
|
+
* by value (deep equality), `false` otherwise
|
|
22238
|
+
*
|
|
22239
|
+
* @param ps1 an order 0,1,2 or 3 bezier curve given as an ordered array of its
|
|
22240
|
+
* control points, e.g. `[[0,0],[1,1],[2,1],[2,0]]`
|
|
22241
|
+
* @param ps2 another bezier curve
|
|
22242
|
+
*
|
|
22243
|
+
* @doc
|
|
22244
|
+
*/
|
|
22245
|
+
function equal_equal(ps1, ps2) {
|
|
22246
|
+
if (ps1 === ps2) {
|
|
22247
|
+
return true;
|
|
22248
|
+
}
|
|
22249
|
+
if (ps1.length !== ps2.length) {
|
|
22250
|
+
return false;
|
|
22251
|
+
}
|
|
22252
|
+
for (let i = 0; i < ps1.length; i++) {
|
|
22253
|
+
if (ps1[i][0] !== ps2[i][0] || ps1[i][1] !== ps2[i][1]) {
|
|
22254
|
+
return false;
|
|
22255
|
+
}
|
|
22256
|
+
}
|
|
22257
|
+
return true;
|
|
22258
|
+
}
|
|
22259
|
+
|
|
22260
|
+
//# sourceMappingURL=equal.js.map
|
|
22230
22261
|
;// CONCATENATED MODULE: ./node_modules/flo-boolean/node/loop/normalize/are-all-points-different.js
|
|
22231
22262
|
/**
|
|
22232
22263
|
* Returns true if all points in the given array are different, false otherwise.
|
|
@@ -22257,6 +22288,9 @@ const { abs: fix_bezier_by_point_spacing_abs } = Math;
|
|
|
22257
22288
|
* @param ps A bezier
|
|
22258
22289
|
*/
|
|
22259
22290
|
function fixBezierByPointSpacing(ps, gridSpacing, sendToGrid) {
|
|
22291
|
+
if (ps === undefined) {
|
|
22292
|
+
return undefined;
|
|
22293
|
+
}
|
|
22260
22294
|
// Early filter - if all points coincide, we're done - degenerate to point
|
|
22261
22295
|
if (isReallyPoint(ps)) {
|
|
22262
22296
|
return undefined; // Cannot fix
|
|
@@ -22276,9 +22310,8 @@ function fixBezierByPointSpacing(ps, gridSpacing, sendToGrid) {
|
|
|
22276
22310
|
// Is the quadratic bezier overlapping onto itself?
|
|
22277
22311
|
if (arePsEqual(ps[0], ps[2])) {
|
|
22278
22312
|
// a quadratic with equal endpoints (and not degenerate to a point)
|
|
22279
|
-
|
|
22280
|
-
//
|
|
22281
|
-
return [ps[0], ps[1]];
|
|
22313
|
+
return undefined; // better to just remove it
|
|
22314
|
+
// return [ps[0], ps[1]];
|
|
22282
22315
|
}
|
|
22283
22316
|
// At this point not all points same and not all points different and
|
|
22284
22317
|
// not endpoints coincide, so either:
|
|
@@ -22290,28 +22323,42 @@ function fixBezierByPointSpacing(ps, gridSpacing, sendToGrid) {
|
|
|
22290
22323
|
// ---- at this point we must have a cubic
|
|
22291
22324
|
// Early filter - if no points coincide, we're done - well spaced
|
|
22292
22325
|
if (areAllPointsDifferent(ps)) {
|
|
22293
|
-
|
|
22326
|
+
const ps_ = checkCubicForLineOrQuad(ps);
|
|
22327
|
+
if (ps_ === undefined) {
|
|
22328
|
+
return undefined;
|
|
22329
|
+
}
|
|
22330
|
+
if (equal_equal(ps_, ps)) {
|
|
22331
|
+
return ps;
|
|
22332
|
+
}
|
|
22333
|
+
return fixBezierByPointSpacing(ps_, gridSpacing, sendToGrid);
|
|
22294
22334
|
}
|
|
22295
22335
|
if (arePsEqual(ps[0], ps[3])) {
|
|
22296
22336
|
// we should simply handle this case for cubics - lines and quadratics
|
|
22297
22337
|
// degenerate into a point and a self-overlapping curve respectively.
|
|
22298
|
-
if (
|
|
22299
|
-
|
|
22300
|
-
return
|
|
22338
|
+
// if (isCollinear(ps)) { return [ps[0], ps[3]]; }
|
|
22339
|
+
if (isCollinear(ps)) {
|
|
22340
|
+
return undefined;
|
|
22301
22341
|
}
|
|
22342
|
+
// if (arePsEqual(ps[1], ps[2])) {
|
|
22343
|
+
// // it is a cubic degenerated to a line
|
|
22344
|
+
// return [ps[0], ps[2]];
|
|
22345
|
+
// }
|
|
22302
22346
|
// no need to fix anything - it is a loop - it cannot be a line or a
|
|
22303
22347
|
// quadratic (they don't make loops)
|
|
22304
22348
|
return ps;
|
|
22305
22349
|
}
|
|
22350
|
+
if (isCollinear(ps)) {
|
|
22351
|
+
return [ps[0], ps[3]];
|
|
22352
|
+
}
|
|
22306
22353
|
// At this point, either:
|
|
22307
22354
|
// * point 0, 1 and 2 coincide
|
|
22308
22355
|
// * point 1, 2 and 3 coincide
|
|
22309
22356
|
// * points 0,1 AND points 2,3 coincide
|
|
22310
|
-
// * only point 0 and point 1
|
|
22311
|
-
// * only point 0 and point 2
|
|
22312
|
-
// * only point 1 and point 2
|
|
22313
|
-
// * only point 1 and point 3
|
|
22314
|
-
// * only point 2 and point 3
|
|
22357
|
+
// * only point 0 and point 1 coincide
|
|
22358
|
+
// * only point 0 and point 2 coincide
|
|
22359
|
+
// * only point 1 and point 2 coincide
|
|
22360
|
+
// * only point 1 and point 3 coincide
|
|
22361
|
+
// * only point 2 and point 3 coincide
|
|
22315
22362
|
// If point 0, 1 and 2 coincide OR point 1, 2 and 3 coincide OR
|
|
22316
22363
|
// points 0,1 AND points 2,3 coincide we have a line
|
|
22317
22364
|
if ((arePsEqual(ps[0], ps[1]) &&
|
|
@@ -22320,17 +22367,24 @@ function fixBezierByPointSpacing(ps, gridSpacing, sendToGrid) {
|
|
|
22320
22367
|
arePsEqual(ps[2], ps[3])) ||
|
|
22321
22368
|
(arePsEqual(ps[0], ps[1]) &&
|
|
22322
22369
|
arePsEqual(ps[2], ps[3]))) {
|
|
22370
|
+
return fixBezierByPointSpacing([ps[0], ps[ps.length - 1]], gridSpacing, sendToGrid);
|
|
22371
|
+
/*
|
|
22323
22372
|
// Check if first and last point are sufficiently far apart to split
|
|
22324
22373
|
// the bezier into a line so that all points differ.
|
|
22325
|
-
|
|
22326
|
-
|
|
22327
|
-
|
|
22328
|
-
|
|
22329
|
-
|
|
22374
|
+
|
|
22375
|
+
// TODO2 - is below maybe not correct?
|
|
22376
|
+
//if ((ps[0][0] - ps[3][0]) > (3+1)*gridSpacing ||
|
|
22377
|
+
// (ps[0][1] - ps[3][1]) > (3+1)*gridSpacing) {
|
|
22378
|
+
if (abs(ps[0][0] - ps[3][0]) > (3+1)*gridSpacing ||
|
|
22379
|
+
abs(ps[0][1] - ps[3][1]) > (3+1)*gridSpacing) {
|
|
22380
|
+
|
|
22381
|
+
return [ps[0], ps[ps.length-1]];
|
|
22382
|
+
} else {
|
|
22330
22383
|
// Points are not sufficiently far apart to resolve onto grid -
|
|
22331
22384
|
// cannot fix it - it is basically a point.
|
|
22385
|
+
|
|
22332
22386
|
return undefined;
|
|
22333
|
-
}
|
|
22387
|
+
}*/
|
|
22334
22388
|
}
|
|
22335
22389
|
// At this point, either:
|
|
22336
22390
|
// * only point 0 and point 1 coincides
|
|
@@ -22360,12 +22414,7 @@ function fixBezierByPointSpacing(ps, gridSpacing, sendToGrid) {
|
|
|
22360
22414
|
// move them onto each other - this shouldn't affect the overall
|
|
22361
22415
|
// accuracy of the algorithm and it ensures the move > gridSpacing.
|
|
22362
22416
|
if (squared_distance_between_squaredDistanceBetween(ps[1], ps[2]) < 4 * gridSpacing) {
|
|
22363
|
-
return [
|
|
22364
|
-
ps[0],
|
|
22365
|
-
ps[2],
|
|
22366
|
-
ps[2],
|
|
22367
|
-
ps[3]
|
|
22368
|
-
]; // cannot be a line or quad
|
|
22417
|
+
return [ps[0], ps[2], ps[2], ps[3]]; // cannot be a line or quad
|
|
22369
22418
|
}
|
|
22370
22419
|
else {
|
|
22371
22420
|
const v = toLength(fromTo(ps[1], ps[2]), 2 * gridSpacing);
|
|
@@ -22728,10 +22777,11 @@ function simplifyPaths(bezierLoops, maxCoordinate) {
|
|
|
22728
22777
|
* A size (based on the max value of the tangent) for the containers holding
|
|
22729
22778
|
* critical points.
|
|
22730
22779
|
*/
|
|
22731
|
-
const containerSizeMultiplier = 2 ** 4;
|
|
22732
|
-
//const containerSizeMultiplier = 2**
|
|
22780
|
+
const containerSizeMultiplier = 2 ** 4; // TODO2 - put back!!
|
|
22781
|
+
// const containerSizeMultiplier = 2**36;
|
|
22733
22782
|
const containerDim = gridSpacing * containerSizeMultiplier;
|
|
22734
22783
|
bezierLoops = normalizeLoops(bezierLoops, maxBitLength, expMax, false, true);
|
|
22784
|
+
// console.log(bezierLoops)
|
|
22735
22785
|
addDebugInfo1(bezierLoops);
|
|
22736
22786
|
bezierLoops.sort(orderLoopAscendingByMinY);
|
|
22737
22787
|
const loops = bezierLoops.map((loop, i) => loopFromBeziers(loop, i));
|