ManimCommunity / ManimCommunity/manim

Bounding box of SVGMobject returned by get_left, get_right, get_top, get_bottom is too small

Open
#3,265 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

## Description of bug / unexpected behavior

Leftmost/rightmost/topmost/bottommost of an SVGMobject are found including only vertices, not paths which results in some parts sticking out of the bounding box as can be seen in the clip below

## How to reproduce the issue
Code for reproducing the problem

```py
import manim

manim.config.background_color = '#101010'

def make_rectangle(left, right, top, bottom):
ret = manim.Rectangle(width = right - left, height = top - bottom, stroke_width=1)
ret.shift(manim.RIGHT * (right + left) / 2, manim.UP * (top + bottom) / 2)
return ret

class Test_Class(manim.Scene):
def construct(self):
directory = 'images/'
emojis = [directory + x + '.svg' for x in ['1F91C', '1F45F', '1F477', '1F939-200D-2642-FE0F', '1F48F', '1F64C', '1F91D', '1F9D1-200D-1F3A8']]
prev = None
for file in emojis:
svg = manim.SVGMobject(file)
svg.scale(2.5)
rec = make_rectangle(svg.get_left()[0], svg.get_right()[0], svg.get_top()[1], svg.get_bottom()[1])
objects = [svg, rec]
if prev is None:
self.play(*(manim.Create(x) for x in objects), run_time=0.5)
prev = objects
```

## Additional media files

Images/GIFs

[images.zip](https://github.com/ManimCommunity/manim/files/11779884/images.zip) (taken from https://openmoji.org/library/)

https://github.com/ManimCommunity/manim/assets/16389252/8d02f89d-196c-4987-afb5-17fb75706e2b

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 SVGMobject and the get_left, get_right, get_top, and get_bottom entry points, then reproduce the issue with the provided emoji SVGs and rectangle comparison. Done means the returned bounds include the full paths rather than only their vertices, with coverage for the reported behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.