Search code examples
pythonsvginkscapemanim

How to properly import an SVG path to manim


I am working on a logo on Inkscape and I would like to import it to manim. The file does import properly with all the paths of the SVG but a weird thing is happening.

My code for running the file is this:

class U_letter(Scene):
    def construct(self):
        letter = SVGMobject("u_letter")
        self.add(letter)
        letter.set_color(GREEN)

The SVG format of the letter I am trying to add is available here.

It currently has two layers and when importing it this way it displays fine on manim but my problem is that I have to set the fill of the 'inner path'(i.e the inside of the letter) to match the background of the scene and I would like to avoid this.

I tried creating a single path out of the letter by using the difference functionality on Inkscape and that's where my problems started because the final image appears distorted as shown here.

I am however looking for something like this as my final solution. I should also point out that I have been experiencing this behavior with other letters I have tried so far, D and A letters to be exact.

Your help would be greatly appreciated


Solution

  • As of current date (June 3, 2020), There is no "proper" way to import a SVG object, as you see, you can you use SVGMObject and it will work most of the time, but as manim parses the path itself it ignores many things from the SVG specification in it's implementation, so you would have to fix it yourself or wait until it is fixed.