35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$svg$utils$pathOperations = function(global, require, module, exports) {
|
|
var GraphicsPath = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$path$GraphicsPath");
|
|
"use strict";
|
|
exports.appendSVGPath = function(pathData, graphicsPath) {
|
|
pathData = new GraphicsPath.GraphicsPath(pathData, !1);
|
|
for (const instruction of pathData.instructions) {
|
|
graphicsPath.instructions.push(instruction);
|
|
}
|
|
};
|
|
exports.calculatePathArea = function(pathData) {
|
|
pathData = pathData.match(/[-+]?[0-9]*\.?[0-9]+/g);
|
|
if (!pathData || 4 > pathData.length) {
|
|
return 0;
|
|
}
|
|
var numbers = pathData.map(Number), xs = [];
|
|
pathData = [];
|
|
for (var i = 0; i < numbers.length; i += 2) {
|
|
i + 1 < numbers.length && (xs.push(numbers[i]), pathData.push(numbers[i + 1]));
|
|
}
|
|
if (0 === xs.length || 0 === pathData.length) {
|
|
return 0;
|
|
}
|
|
numbers = Math.min(...xs);
|
|
xs = Math.max(...xs);
|
|
i = Math.min(...pathData);
|
|
pathData = Math.max(...pathData);
|
|
return (xs - numbers) * (pathData - i);
|
|
};
|
|
exports.extractSubpaths = function(pathData) {
|
|
return pathData.split(/(?=[Mm])/).filter(part => 0 < part.trim().length);
|
|
};
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$svg$utils$pathOperations.js.map
|