Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to return SVG as JSON Array #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

chiq2045
Copy link

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
Copy link
Owner

Interesting.

Seems relatively straightforward. Couple points:

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

@chiq2045
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants