Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.default = function (imageData, params) {
if ((0, _isImageData2.default)(imageData)) {
var imageSize = { width: imageData.width, height: imageData.height };
var tmpImageData = (0, _copyImageData2.default)(imageData);
var colorImageData = (0, _copyImageData2.default)(imageData);
var blurredImageData = (0, _stackblurCanvas.imageDataRGBA)(tmpImageData, 0, 0, imageSize.width, imageSize.height, params.blur);
var greyscaleImageData = (0, _greyscale2.default)(blurredImageData);
var edgesImageData = (0, _sobel2.default)(greyscaleImageData).toImageData();
var edgePoints = (0, _getEdgePoints2.default)(edgesImageData, params.threshold);
var edgeVertices = (0, _getVerticesFromPoints2.default)(edgePoints, params.vertexCount, params.accuracy, imageSize.width, imageSize.height);
var polygons = (0, _delaunayFast.triangulate)(edgeVertices);
polygons = (0, _addBoundingBoxesToPolygons2.default)(polygons);
if (!params.transparentColor) {
polygons = (0, _filterTransparentPolygons2.default)(polygons, colorImageData);
}
if (params.fill === true && params.gradients === true) {
polygons = (0, _addGradientsToPolygons2.default)(polygons, colorImageData, params);
} else {
polygons = (0, _addColorToPolygons2.default)(polygons, colorImageData, params);