Improve the SVG parser
See original GitHub issueThere are many weird quirks of the current custom SVG parser. For example, the colors white and black are swapped if the SVG element is a rect. This is some really odd behavior, and I think the best way to solve these issues is to use a full SVG parsing library.
Either way, SVG support is pretty limited at the moment. (Also, I think I can add SkewX and SkewY transform support right now)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:19 (19 by maintainers)
Top Results From Across the Web
Improving SVG Runtime Performance - CodePen
Receiving and decoding data from the network takes CPU. The less of that, the more cycles left over for rendering. Plus, parse time...
Read more >C/C++ library to parse SVG files?
New SVG++ library is a good choice for SVG reading in C++, except that it is not lightweight and requires Boost library.
Read more >Python SVG parser - Stack Overflow
Ignoring transforms, you can extract the path strings from an SVG like so: from xml.dom import minidom doc = minidom.parse(svg_file) # parseString also ......
Read more >SVG++ 1.2.1 released: Most advanced SVG reading library for ...
Can I use to build a SVG ? What are you using Boost for ? XML parsing and blas ?
Read more >Re: Go SVG Parser? - Google Groups
I needed to manipulate SVG files, so I wrote a program (in Go) to put the SVG in to a generic tree (using...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, I was trying to improve the svg parser sometime ago, but during my attempt, I found if we want to improve it (more stable and powerful), we need to deal with some problems first.
We need to let
SVGMobjectsupport<text>,<image>and so on. But currentlySVGMobjectis a subclass ofVMobject. I think we should letSVGMobjectbecome a subclass ofGroup, which I think is more intuitive. But then you will find thatGroupdoesn’t support many existingAnimationse.g.Write, and you will also notice that there is a subclass ofVMobjectcalledVGroup, so far, I have made a new class calledImagewhich is a subclass ofVMobject/.../Rectangleand is able to be animated in thoseAnimations, but I think it is a compromised way. Then we need to dig into the deepest process of manim, if you are interested, please tell me, because I think this is a little offtopic…We need to PARSE svg in a better way in order to let it support attributes like
color,strokeand so on. I found a python package calledcairosvg, which does this job almost perfectly, but it can’t be used directly in manim, so I think we can probably look into the source code of it and use(copy) some of it such as its class calledTreeBecause I’m busy with other things now and don’t have much time to do it. If you want to improve it, I hope my experience can help a little…
I just use the name
Imageto distinguish the currentImageMobject, but I think using the nameImage,Text,Tex,SVG, is simpler and more convince to use from user‘s perspective thanImageMobject,TextMobject,TexMobject,SVGMobject(though they are not the same thing currently).The confusion of the PIL Image can probably be solved by using
PIL.Image.Maybe we can do something like this:
and create a abbreviation version
But this is not very important…