flatten-svg
Advanced tools
Comparing version 0.2.1 to 0.3.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var svg_to_paths_1 = require("./svg-to-paths"); | ||
exports.flattenSVG = svg_to_paths_1.flattenSVG; | ||
Object.defineProperty(exports, "flattenSVG", { enumerable: true, get: function () { return svg_to_paths_1.flattenSVG; } }); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.flattenSVG = void 0; | ||
const path_data_polyfill_1 = require("./path-data-polyfill"); | ||
@@ -95,2 +96,8 @@ function isFlatEnough([x0, y0, x1, y1, x2, y2, x3, y3], flatness) { | ||
} | ||
function point(x, y) { | ||
const pt = [x, y]; | ||
pt.x = x; | ||
pt.y = y; | ||
return pt; | ||
} | ||
function flattenSVG(svg, options = {}) { | ||
@@ -103,3 +110,3 @@ const { maxError = 0.1 } = options; | ||
const xf = ctm == null | ||
? ([x, y]) => { return [x, y]; } | ||
? ([x, y]) => { return point(x, y); } | ||
: ([x, y]) => { | ||
@@ -109,3 +116,3 @@ svgPoint.x = x; | ||
const xfd = svgPoint.matrixTransform(ctm); | ||
return [xfd.x, xfd.y]; | ||
return point(xfd.x, xfd.y); | ||
}; | ||
@@ -137,5 +144,5 @@ const pathData = path_data_polyfill_1.getPathData(shape, { normalize: true }); | ||
for (const part of parts) { | ||
paths[paths.length - 1].points.push([part[6], part[7]]); | ||
paths[paths.length - 1].points.push(point(part[6], part[7])); | ||
} | ||
cur = [tx3, ty3]; | ||
cur = point(tx3, ty3); | ||
} | ||
@@ -196,5 +203,5 @@ else if (cmd.type === 'A') { | ||
const ty = sin(phi) * rx * cos(theta) + cos(phi) * ry * sin(theta) + cy; | ||
paths[paths.length - 1].points.push([tx, ty]); | ||
paths[paths.length - 1].points.push(point(tx, ty)); | ||
} | ||
cur = [x, y]; | ||
cur = point(x, y); | ||
} | ||
@@ -201,0 +208,0 @@ else if (cmd.type === 'Z') { |
{ | ||
"name": "flatten-svg", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "", | ||
@@ -21,6 +21,6 @@ "main": "dist/index.js", | ||
"@types/jest": "^24.0.11", | ||
"jest": "^24.5.0", | ||
"ts-jest": "^24.0.0", | ||
"typescript": "^3.3.3333", | ||
"svgdom": "0.0.18" | ||
"jest": "^26.0.0", | ||
"svgdom": "0.0.18", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^3.3.3333" | ||
}, | ||
@@ -27,0 +27,0 @@ "files": [ |
@@ -65,3 +65,5 @@ # flatten-svg | ||
Properties: | ||
* `points` \[number, number][] - list of points on the line | ||
* `points` (\[number, number] & {x: number, y: number})[] - list of points on the line | ||
* `stroke` ?string - if present, the `stroke` property of the line | ||
Points on the line are two-element arrays ([x, y]), but also have .x and .y properties. |
Sorry, the diff of this file is not supported yet
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
88610
1083
69