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

SVG support on top of this? #4

Open
ensisoft opened this issue Jan 27, 2023 · 3 comments
Open

SVG support on top of this? #4

ensisoft opened this issue Jan 27, 2023 · 3 comments

Comments

@ensisoft
Copy link

Hi,

this is an interesting looking little library. Any idea about the amount of work needed to build an SVG renderer out of this? I work on a game engine and I'm interested in exploring an integration of tiny SVG rendered for scalable resolution independent graphics.

Thanks!

@a-e-k
Copy link
Owner

a-e-k commented Feb 1, 2023

Thanks! Both rendering vector assets for games and rendering a subset of SVG are applications that I'd had in mind for this library. In fact, I'd looked into a while back as a potential side project, but didn't want to get too sidetracked from just getting this library to release.

There are few avenues that I can see for this:

  1. Build a little library that directly parses a subset of SVG and makes calls into canvas_ity to do the rendering. Or if you want something already written for this purpose, have a look at NanoSVG. As I understand it, canvas_ity is a much more fully-featured renderer than the one included with NanoSVG and so should make a good back-end for it.

  2. Take a more heavy-weight existing SVG parser and adapt it to flatten the SVG to a series of calls to a canvas-like API which are then serialized. Those then become your cooked assets and you just have a very thin layer that deserializes them and calls canvas_ity. I've had some success at using Inkscape's HTML5 canvas export function to try this for a few SVG files such as the PostScript Tiger. After exporting, I'd load the generated JavaScript into my editor and do regexp search and replaces until I'd turned it into the C++ equivalent that calls canvas_ity. As another potential side project, I've been mulling binary serialized canvas API calls as a lightweight vector image format.

Cheers!

@ensisoft
Copy link
Author

ensisoft commented Feb 1, 2023

Thanks for the answer!

Regarding NanoSVG if there's some kind of glue code that is needed to plug these two together is that a contribution you'd be interested in having in your repo?

@a-e-k
Copy link
Owner

a-e-k commented Feb 4, 2023

For now, I'd like to keep this repo fairly slim. But if you do write such glue code and put it in your own repo, I'll be happy to add a link to it on the README here.

@rburchell rburchell mentioned this issue Feb 26, 2024
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

No branches or pull requests

2 participants