49 lines
2.3 KiB
JavaScript
49 lines
2.3 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$buildCommands$buildAdaptiveBezier = function(global, require, module, exports) {
|
|
function recursive(x1, y1, x2, y2, x3, y3, x4, y4, points, distanceTolerance, level) {
|
|
if (!(8 < level)) {
|
|
var x12 = (x1 + x2) / 2, y12 = (y1 + y2) / 2, x23 = (x2 + x3) / 2, y23 = (y2 + y3) / 2, x34 = (x3 + x4) / 2, y34 = (y3 + y4) / 2, x123 = (x12 + x23) / 2, y123 = (y12 + y23) / 2;
|
|
x23 = (x23 + x34) / 2;
|
|
y23 = (y23 + y34) / 2;
|
|
var x1234 = (x123 + x23) / 2, y1234 = (y123 + y23) / 2;
|
|
if (0 < level) {
|
|
let dx = x4 - x1, dy = y4 - y1;
|
|
x2 = Math.abs((x2 - x4) * dy - (y2 - y4) * dx);
|
|
x3 = Math.abs((x3 - x4) * dy - (y3 - y4) * dx);
|
|
if (11920929e-14 < x2 && 11920929e-14 < x3) {
|
|
if ((x2 + x3) * (x2 + x3) <= distanceTolerance * (dx * dx + dy * dy)) {
|
|
points.push(x1234, y1234);
|
|
return;
|
|
}
|
|
} else if (11920929e-14 < x2) {
|
|
if (x2 * x2 <= distanceTolerance * (dx * dx + dy * dy)) {
|
|
points.push(x1234, y1234);
|
|
return;
|
|
}
|
|
} else if (11920929e-14 < x3) {
|
|
if (x3 * x3 <= distanceTolerance * (dx * dx + dy * dy)) {
|
|
points.push(x1234, y1234);
|
|
return;
|
|
}
|
|
} else {
|
|
if (dx = x1234 - (x1 + x4) / 2, dy = y1234 - (y1 + y4) / 2, dx * dx + dy * dy <= distanceTolerance) {
|
|
points.push(x1234, y1234);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
recursive(x1, y1, x12, y12, x123, y123, x1234, y1234, points, distanceTolerance, level + 1);
|
|
recursive(x1234, y1234, x23, y23, x34, y34, x4, y4, points, distanceTolerance, level + 1);
|
|
}
|
|
}
|
|
var GraphicsContextSystem = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$GraphicsContextSystem");
|
|
"use strict";
|
|
exports.buildAdaptiveBezier = function(points, sX, sY, cp1x, cp1y, cp2x, cp2y, eX, eY, smoothness) {
|
|
smoothness = 1 - Math.min(0.99, Math.max(0, smoothness ?? GraphicsContextSystem.GraphicsContextSystem.defaultOptions.bezierSmoothness));
|
|
recursive(sX, sY, cp1x, cp1y, cp2x, cp2y, eX, eY, points, smoothness * smoothness, 0);
|
|
points.push(eX, eY);
|
|
return points;
|
|
};
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$buildCommands$buildAdaptiveBezier.js.map
|