node-potrace icon indicating copy to clipboard operation
node-potrace copied to clipboard

Add function to return SVG as JSON Array

Open chiq2045 opened this issue 5 years ago • 2 comments

In addition to returning SVG document contents, a tag, and a tag, this pull request adds the ability to return a JSON Array of the SVG paths, getJSON(). This allows users to create their own SVGs using the given paths, and allows for easier data manipulation. The information returned from the new function is similar to what is returned from the other functions. It holds the width and height data of the svg, and the data of each of the svg's created paths.

The structure of the resulting array is as follows:

[
  {
    height: 320,
    width: 240
  },
  {
    d: "M 636.282 50.537 C 628.002 52.767, ...",
    id: 1,
    fill: "black",
    stroke: "black",
    fillRule: "evenodd"
  },
  {
    d: "M 639.487 67.746 C 632.040 70.400, ...",
    id: 2,
    fill: "black",
    stroke: "black",
    fillRule: "evenodd"
  },
  ...
]

chiq2045 avatar Aug 26 '20 01:08 chiq2045

Interesting.

Seems relatively straightforward. Couple points:

  • There's a conflict in package-lock.json currently
  • Could we get a test?

tooolbox avatar Aug 28 '20 03:08 tooolbox

I have bumped the version number in package.json. That was the conflict that you mentioned. I will now add some tests.

chiq2045 avatar Aug 28 '20 04:08 chiq2045