32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$utils$getMaxMiterRatio = function(global, require, module, exports) {
|
|
exports.getMaxMiterRatio = function(path, miterLimit) {
|
|
let maxRatio = 1;
|
|
path = path.shapePath.shapePrimitives;
|
|
for (let i = 0; i < path.length; i++) {
|
|
var shape = path[i].shape;
|
|
if ("polygon" !== shape.type) {
|
|
continue;
|
|
}
|
|
const points = shape.points, n = points.length;
|
|
if (!(6 > n)) {
|
|
shape = shape.closePath;
|
|
for (let j = 0; j < n; j += 2) {
|
|
if (!shape && (0 === j || j === n - 2)) {
|
|
continue;
|
|
}
|
|
var prevIdx = (j - 2 + n) % n, nextIdx = (j + 2) % n, x1 = points[j], y1 = points[j + 1], dx0 = points[prevIdx] - x1;
|
|
prevIdx = points[prevIdx + 1] - y1;
|
|
x1 = points[nextIdx] - x1;
|
|
nextIdx = points[nextIdx + 1] - y1;
|
|
y1 = dx0 * dx0 + prevIdx * prevIdx;
|
|
const len1Sq = x1 * x1 + nextIdx * nextIdx;
|
|
1e-12 > y1 || 1e-12 > len1Sq || (dx0 = (dx0 * x1 + prevIdx * nextIdx) / Math.sqrt(y1 * len1Sq), -1 > dx0 ? dx0 = -1 : 1 < dx0 && (dx0 = 1), dx0 = Math.sqrt(0.5 * (1 - dx0)), 1e-6 > dx0 || (dx0 = Math.min(1 / dx0, miterLimit), dx0 > maxRatio && (maxRatio = dx0)));
|
|
}
|
|
}
|
|
}
|
|
return maxRatio;
|
|
};
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$utils$getMaxMiterRatio.js.map
|