3b1b / manim

Animation engine for explanatory math videos
MIT License
61.81k stars 5.75k forks source link

Render SVG from Draw.io #671

Open alex-lairan opened 5 years ago

alex-lairan commented 5 years ago

Hi, I'm trying to display some SVG from Draw.io, but I got some strange results.

I want to use manim for development and programming videos :smile:

The code :

class Uml(SVGMobject):
  CONFIG = {
    "file_name": "/home/necros/Downloads/FormObjects-Models.svg",
    "unpack_groups": False
  }

class UmlRender(Scene):
  def construct(self):
    uml = Uml()
    uml.scale(5)

    self.play(DrawBorderThenFill(uml), run_time=5)
    self.wait(5)

Expected result : 2019-08-05-231334_433x377_scrot

Actual result :

2019-08-05-231318_916x851_scrot

Exemple file : https://filebin.net/vhs2w1zlwbqeadhv/FormObjects-Models__1_.svg?t=byk639bd

In hope you have any idea to help me.

Regards

xy-23 commented 5 years ago

I try to download your file from https://srv-file2.gofile.io/download/ANL8aV/FormObjects-Models.svg but it said You are not authorized to download this file.

alex-lairan commented 5 years ago

Oh, I change the provider : https://filebin.net/vhs2w1zlwbqeadhv/FormObjects-Models__1_.svg?t=byk639bd

xy-23 commented 5 years ago

The best result I can get:

class Uml(SVGMobject):
  CONFIG = {
    "file_name": "/home/necros/Downloads/FormObjects-Models.svg",
    "fill_opacity":0,
    "stroke_color": WHITE,
    "stroke_width": 1,
  }

Test

I think there are multiple reasons caused this problem.

  1. Because manim uses a simple(handmade) svg parser. to translate svg into SVGMobject. Manim can't recognize the color and other settings of a svg.(It's not a bad thing)
  2. Because manim can't get those settings, so manim don't know where to stroke, where to fill.

I think this problem can't be solved very quickly, you can create those Graphics by using Mobject like Rectangle(), TextMobject(), Arrow(), line()

shailvaidya commented 3 years ago

Did you find a solution? I am getting a similar issue. I am using the cicuitikz package to draw some circuits in Latex and then animate using manim. The SVG file created is correct and all components are shows correctly. But manim ommits some lines from the figure. I think its some issue with the parser.

alex-lairan commented 3 years ago

No sorry, I gave up this issue and tried to animate the block myself.

Each arrows are just a simple Arrow(block1, block2)

JacksonZ03 commented 1 month ago

The solution I found is to import into Adobe Illustrator, select all, and then go to Edit -> Compound Path -> Release

Sometimes Edit -> Compound Path -> Make also works