You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our options are: glsvg, which is easy and should work. Maybe be issues with multiple svgs at the same time (which is a problem).
pyrsvg, a standard for vector raserization. Requires the hefty GTK libraries though.
Wrapping a C++ solution? nanosvg seems like a possibility, but at this point it might even be easier to write a rasterizer (and use an existing Python parser).
I think we should start with glsvg and then try to push as many SVGs into the program as we can. If the maximum number turns out to be something like 1000, we can probably say "It's OK" since I doubt anyone would use 1000 SVGs anyways. 😛
So, you aren't getting 1000 SVGs. You get one. I just tested glsvg, and well, the bug reported here is accurate. I will see if I can maybe fix this bug, but that is a significant issue. Also, if your curious, my code example that only renders one SVG.
I'll report back if I make any progress
Oh, or as an utter hack, we might be able to try off screen rasterization using glsvg, then deal only in bitmaps. Either way, I will experiment with what is possible.
If we go the route of rasterize once, we will need to rasterize at a high resolution, else we might get bad scaling. Which would increase time to rasterize. I will try to work on this today and tomorrow. The documentation for PyOpenGL is not the best, but I think I can piece things together.
@Tymewalk I think we can just add a little bit to where people add the costume (I assume they must give a file path), if it has an svg or svgz file extension, we use glsvg and off screen rendering.
If we go the route of rasterize once, we will need to rasterize at a high resolution, else we might get bad scaling. Which would increase time to rasterize
It might be a good idea to look into creating our own SVG renderer.
will try to work on this today and tomorrow. The documentation for PyOpenGL is not the best, but I think I can piece things together.
It might be a good idea to look into creating our own SVG renderer.
Whew, that would be a lot of work. Maybe. I would rather wrap a C++ one for speed.
Also, as for speed of the rasterization, I have no idea. I will have to experiment. OpenGL uses the GPU, so it should be fast, but with Python.... I don't know.
As for pyrsvg, it is not included in the Python distribution, and depends on the GTK+ runtime (I just checked install size ~165mb).
@ironmanmark20 Yeah, they do specify a file path. With split it shouldn't be too hard to check.
As for pyrsvg, it is not included in the Python distribution, and depends on the GTK+ runtime (I just checked install size ~165mb).
I was asking if GTK comes pre-installed, but I'll take that as a no.
165 MB is a little much. Maybe there could be a no-SVG version of Slither that doesn't require it?
Or maybe it checks if GTK is installed, and if not, doesn't support SVGs, but still lets you use Slither without them.
We could say that if they have node.js installed we will be able to handle svgs, otherwise we will throw an error when the user tries to use a svg just like we do now.
We could create a cache dir to put the pngs in and then delete it when we exit. Also, I think that it should be possible to get the setup.py to install it for us.
@Tymewalk@ethanhs, I just found out that if we restrict ourselves to just Python 3.4+, we can use CarioSVG to rasterize the SVGs to PNGs. They say that it works on all platforms, and installing it is as easy aspip install cairosvg, so we could add it as a dependency.
OK, it turns out that the user still needs to have cairo installed, BUT, I've found out that it should be easy to build a stand-alone cairo DLL that we can include for Windows, and we just need to run a simple shell command to get it to install on OS X and Linux.
Activity
Tymewalk commentedon Mar 29, 2016
I think we should start with glsvg and then try to push as many SVGs into the program as we can. If the maximum number turns out to be something like 1000, we can probably say "It's OK" since I doubt anyone would use 1000 SVGs anyways. 😛
emmatyping commentedon Mar 30, 2016
So, you aren't getting 1000 SVGs. You get one. I just tested glsvg, and well, the bug reported here is accurate. I will see if I can maybe fix this bug, but that is a significant issue. Also, if your curious, my code example that only renders one SVG.
I'll report back if I make any progress
Oh, or as an utter hack, we might be able to try off screen rasterization using glsvg, then deal only in bitmaps. Either way, I will experiment with what is possible.
BookOwl commentedon Mar 30, 2016
That's really bad.
That sounds like it could work.
I'm starting to think that writing our own rasterizer might be the best option.
Tymewalk commentedon Mar 30, 2016
YIKES.
How big are the GTK libraries, and do they come installed by default? I'm considering pyrsvg.
Will it slow things down if we use it a lot? Or if a sprite constantly rescales itself?
BookOwl commentedon Mar 30, 2016
@Tymewalk, if we do offscreen rasterization, I think that we would do it once and scale and rotate the rasterized image.
Tymewalk commentedon Mar 30, 2016
@BookOwl OK, so here's how I understand the workflow:
emmatyping commentedon Mar 30, 2016
If we go the route of rasterize once, we will need to rasterize at a high resolution, else we might get bad scaling. Which would increase time to rasterize. I will try to work on this today and tomorrow. The documentation for PyOpenGL is not the best, but I think I can piece things together.
@Tymewalk I think we can just add a little bit to where people add the costume (I assume they must give a file path), if it has an svg or svgz file extension, we use glsvg and off screen rendering.
BookOwl commentedon Mar 30, 2016
It might be a good idea to look into creating our own SVG renderer.
Thanks for working on it!
emmatyping commentedon Mar 30, 2016
Whew, that would be a lot of work. Maybe. I would rather wrap a C++ one for speed.
Also, as for speed of the rasterization, I have no idea. I will have to experiment. OpenGL uses the GPU, so it should be fast, but with Python.... I don't know.
As for pyrsvg, it is not included in the Python distribution, and depends on the GTK+ runtime (I just checked install size ~165mb).
Tymewalk commentedon Mar 30, 2016
@ironmanmark20 Yeah, they do specify a file path. With
splitit shouldn't be too hard to check.I was asking if GTK comes pre-installed, but I'll take that as a no.
165 MB is a little much. Maybe there could be a no-SVG version of Slither that doesn't require it?
Or maybe it checks if GTK is installed, and if not, doesn't support SVGs, but still lets you use Slither without them.
38 remaining items
Tymewalk commentedon Sep 11, 2016
@BookOwl Then what to do if they don't have it installed?
Will we just warn them or is it a hard dependency?
BookOwl commentedon Sep 11, 2016
We could say that if they have node.js installed we will be able to handle svgs, otherwise we will throw an error when the user tries to use a svg just like we do now.
Tymewalk commentedon Sep 11, 2016
OK. In the installation instructions we can also include that they have to install that module.
Where would the rasterized PNGs go, though?
BookOwl commentedon Sep 11, 2016
We could create a cache dir to put the pngs in and then delete it when we exit. Also, I think that it should be possible to get the setup.py to install it for us.
Tymewalk commentedon Sep 11, 2016
@BookOwl OK then.
Should we remove the "hard" label? It seems like it's just a matter of getting a new program to play nice with our code.
emmatyping commentedon Sep 11, 2016
You can run arbitrary python code in setup.py, so installing it shouldn't be a problem
BookOwl commentedon Sep 12, 2016
@Tymewalk @ethanhs, I just found out that if we restrict ourselves to just Python 3.4+, we can use CarioSVG to rasterize the SVGs to PNGs. They say that it works on all platforms, and installing it is as easy as
pip install cairosvg, so we could add it as a dependency.BookOwl commentedon Sep 12, 2016
OK, it turns out that the user still needs to have cairo installed, BUT, I've found out that it should be easy to build a stand-alone cairo DLL that we can include for Windows, and we just need to run a simple shell command to get it to install on OS X and Linux.
BookOwl commentedon Sep 12, 2016
(so that I can remember where the instructions are) https://www.cairographics.org/end_to_end_build_for_win32/
https://github.com/Automattic/node-canvas/wiki/Installation---OSX
https://www.cairographics.org/download/
(on home-brew)
brew install cairoBookOwl commentedon Sep 12, 2016
I started a PR in #81BookOwl commentedon Sep 13, 2016
PR #83 adds this
Tymewalk commentedon Sep 19, 2016
#83 was just merged. Which means that after half a year, Slither FINALLY supports SVGs.
It is beautiful.