flatten-svg
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -69,2 +69,12 @@ "use strict"; | ||
} | ||
function getStroke(shape) { | ||
const explicitStroke = shape.getAttribute('stroke') || shape.style.stroke; | ||
if (explicitStroke) { | ||
return explicitStroke; | ||
} | ||
else if (shape.parentNode) { | ||
return getStroke(shape.parentNode); | ||
} | ||
return null; | ||
} | ||
function flattenSVG(svg, options = {}) { | ||
@@ -74,5 +84,4 @@ const { maxError = 0.1 } = options; | ||
const paths = []; | ||
for (const path of walkSvgShapes(svg)) { | ||
const type = path.nodeName.toLowerCase(); | ||
const ctm = path.getCTM(); | ||
for (const shape of walkSvgShapes(svg)) { | ||
const ctm = shape.getCTM(); | ||
const xf = ctm == null | ||
@@ -86,3 +95,3 @@ ? ([x, y]) => { return [x, y]; } | ||
}; | ||
const pathData = path_data_polyfill_1.getPathData(path, { normalize: true }); | ||
const pathData = path_data_polyfill_1.getPathData(shape, { normalize: true }); | ||
let cur = null; | ||
@@ -96,5 +105,3 @@ let closePoint = null; | ||
points: [cur], | ||
stroke: path.getAttribute('stroke') | ||
// getComputedStyle doesn't seem to work until the JS loop that inserted it is done... | ||
// stroke: path.getComputedStyle(path).stroke | ||
stroke: getStroke(shape), | ||
}); | ||
@@ -101,0 +108,0 @@ } |
{ | ||
"name": "flatten-svg", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87134
1059