ManimCommunity / ManimCommunity/manim

SVGMobject doesn't care for width and height defined in SVG

Open
#1,390 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue:bug SVG
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior
While playing around with https://github.com/ManimCommunity/manim/pull/1361, I have an SVG, [a4dae70e0eb51266.txt](https://github.com/ManimCommunity/manim/files/6358293/a4dae70e0eb51266.txt), converted to `.txt`, where the width and height element are not taken into account while displaying.

Using Inkscape's, export to png.
![a4dae70e0eb51266](https://user-images.githubusercontent.com/49693820/115717559-e9a18d00-a397-11eb-8713-9185fdfadc74.png)

Trying the same with this Code in Manim
```py
from manim import *
config["background_color"] = WHITE
class HelloWorld(Scene):
def construct(self):
text = SVGMobject('a4dae70e0eb51266.svg')
self.add(text)
```
I get rendering with `manim -psql test.py`
![HelloWorld_ManimCE_v0 5 0](https://user-images.githubusercontent.com/49693820/115717818-2cfbfb80-a398-11eb-891a-98bc07473748.png)

## Expected behavior
What I am expecting is that the PNG rendered using Manim similar to rendered using Manim to match that of Inkscape. With bounding boxes and width and height element matching that of the SVG.

## How to reproduce the issue

Code for reproducing the problem

```py
from manim import *
config["background_color"] = WHITE
class HelloWorld(Scene):
def construct(self):
text = SVGMobject('a4dae70e0eb51266.svg')
self.add(text)
```

## Additional media files

Images/GIFs

![HelloWorld_ManimCE_v0 5 0](https://user-images.githubusercontent.com/49693820/115717818-2cfbfb80-a398-11eb-891a-98bc07473748.png)

## Additional comments
On the other hand, I would like SVGMobject to draw things with the same size as the SVG itself and give a warning or something asking the user's to scale if the SVG has gone out of the screen or something. That would be super helpful for the `Text` and `Tex` objects because the consistency of size would be the size. For example, the `size` parameter will never work as expected with `Text` because the SVG is scaled and not drawn according to the size.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SVGMobject entry point and run the provided HelloWorld reproduction using a4dae70e0eb51266.svg, then compare its output with the Inkscape PNG. Trace how the SVG width, height, and bounding box are handled; done means Manim renders the SVG at the expected dimensions or clearly warns when scaling is needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.