Provide Better Attribution To Library Code

This commit is contained in:
Caleb Braaten 2024-04-03 18:10:58 -07:00
parent 819ffca552
commit a7f7f8a83d

View File

@ -1,3 +1,7 @@
// Author: https://github.com/Pomax
// License: MIT
// Source: https://github.com/Pomax/bezierjs/blob/master/src/utils.js
// math-inlining.
const { abs, cos, sin, acos, atan2, sqrt, pow } = Math;
@ -409,7 +413,7 @@ const utils = {
(p1.x + p2.x) / 2,
(p1.y + p2.y) / 2,
p2.x,
p2.y
p2.y,
);
},
@ -436,7 +440,7 @@ const utils = {
bbox1,
s2,
bbox2,
curveIntersectionThreshold
curveIntersectionThreshold,
) {
if (!utils.bboxoverlap(bbox1, bbox2)) return [];
const intersections = [];
@ -477,7 +481,7 @@ const utils = {
shape.bbox,
s2,
s2.bbox,
curveIntersectionThreshold
curveIntersectionThreshold,
);
};
return shape;
@ -678,7 +682,7 @@ const utils = {
num = sqrt(
pow(d.y * dd.z - dd.y * d.z, 2) +
pow(d.z * dd.x - dd.z * d.x, 2) +
pow(d.x * dd.y - dd.x * d.y, 2)
pow(d.x * dd.y - dd.x * d.y, 2),
);
dnm = pow(qdsum + d.z * d.z, 3 / 2);
} else {
@ -823,7 +827,7 @@ const utils = {
pairs.forEach(function (pair) {
results = results.concat(
utils.pairiteration(pair.left, pair.right, threshold)
utils.pairiteration(pair.left, pair.right, threshold),
);
});
@ -976,7 +980,15 @@ class PolyBezier {
**/
// math-inlining.
const { abs: abs$1, min, max, cos: cos$1, sin: sin$1, acos: acos$1, sqrt: sqrt$1 } = Math;
const {
abs: abs$1,
min,
max,
cos: cos$1,
sin: sin$1,
acos: acos$1,
sqrt: sqrt$1,
} = Math;
const pi$1 = Math.PI;
/**
@ -1010,7 +1022,7 @@ class Bezier {
if (coordlen > 4) {
if (arguments.length !== 1) {
throw new Error(
"Only new Bezier(point[]) is accepted for 4th and higher order curves"
"Only new Bezier(point[]) is accepted for 4th and higher order curves",
);
}
higher = true;
@ -1019,7 +1031,7 @@ class Bezier {
if (len !== 6 && len !== 8 && len !== 9 && len !== 12) {
if (arguments.length !== 1) {
throw new Error(
"Only new Bezier(point[]) is accepted for 4th and higher order curves"
"Only new Bezier(point[]) is accepted for 4th and higher order curves",
);
}
}
@ -1049,7 +1061,8 @@ class Bezier {
// is this curve, practically speaking, a straight line?
const aligned = utils.align(points, { p1: points[0], p2: points[order] });
const baselength = utils.dist(points[0], points[order]);
this._linear = aligned.reduce((t, p) => t + abs$1(p.y), 0) < baselength / 50;
this._linear =
aligned.reduce((t, p) => t + abs$1(p.y), 0) < baselength / 50;
this._lut = [];
@ -1454,7 +1467,7 @@ class Bezier {
return t >= 0 && t <= 1;
});
roots = roots.concat(result[dim].sort(utils.numberSort));
}.bind(this)
}.bind(this),
);
result.values = roots.sort(utils.numberSort).filter(function (v, idx) {
@ -1470,7 +1483,7 @@ class Bezier {
this.dims.forEach(
function (d) {
result[d] = utils.getminmax(this, d, extrema[d]);
}.bind(this)
}.bind(this),
);
return result;
}
@ -1604,7 +1617,7 @@ class Bezier {
this.points.map((p, i) => ({
x: p.x + v.x * d[i],
y: p.y + v.y * d[i],
}))
})),
);
}
@ -1627,7 +1640,7 @@ class Bezier {
return this.translate(
this.normal(0),
distanceFn ? distanceFn(0) : d,
distanceFn ? distanceFn(1) : d
distanceFn ? distanceFn(1) : d,
);
}
@ -1742,10 +1755,10 @@ class Bezier {
const slen = segment.length();
if (graduated) {
fcurves.push(
segment.scale(linearDistanceFunction(d1, d3, tlen, alen, slen))
segment.scale(linearDistanceFunction(d1, d3, tlen, alen, slen)),
);
bcurves.push(
segment.scale(linearDistanceFunction(-d2, -d4, tlen, alen, slen))
segment.scale(linearDistanceFunction(-d2, -d4, tlen, alen, slen)),
);
} else {
fcurves.push(segment.scale(d1));
@ -1787,7 +1800,7 @@ class Bezier {
const shape = utils.makeshape(
outline[i],
outline[len - i],
curveIntersectionThreshold
curveIntersectionThreshold,
);
shape.startcap.virtual = i > 1;
shape.endcap.virtual = i < len / 2 - 1;
@ -1807,7 +1820,7 @@ class Bezier {
return this.curveintersects(
this.reduce(),
curve,
curveIntersectionThreshold
curveIntersectionThreshold,
);
}
@ -1856,7 +1869,7 @@ class Bezier {
const result = utils.pairiteration(
pair.left,
pair.right,
curveIntersectionThreshold
curveIntersectionThreshold,
);
if (result.length > 0) {
intersections = intersections.concat(result);