tooolbox / node-potrace

JavaScript port of Potrace, for NodeJS
GNU General Public License v2.0
388 stars 34 forks source link

Add function to return SVG as JSON Array #12

Open chiq2045 opened 4 years ago

chiq2045 commented 4 years ago

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"
  },
  ...
]
tooolbox commented 4 years ago

Interesting.

Seems relatively straightforward. Couple points:

chiq2045 commented 4 years ago

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