ManimCommunity / ManimCommunity/manim
z_index of SVGMobject does not work correctly
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## Description of bug / unexpected behavior
Setting the z_index of an SVGMobject to a value greater than 0 does not have the desired effect.
## Expected behavior
If there is an Mobject with a given z_index, say 1, and an SVGMobject with larger z_index, say 2, the SVGMobject should be displayed in front of the other Mobject.
## How to reproduce the issue
The code below creates a rectangle with z_index 1 and a Text, Dot and SVGMobjet with z_index 2. The dot is displayed correctly in front of the rectangle. The SVGMobject and the Text (which inherits from SVGMobject) are displayed incorrectly behind the rectangle.
```py
import manim
class Test(manim.Scene):
def construct(self):
rect = manim.Rectangle(fill_color=manim.YELLOW, fill_opacity=1, z_index=1)
self.add(rect)
text = manim.Text("Hello", z_index=2, color=manim.RED).move_to(rect.get_left())
self.add(text) # displayed incorrectly behind the rectangle
dot = manim.Dot(rect.get_right(), z_index=2, radius=1/2, color=manim.RED)
self.add(dot) # displayed correctly in front of the rectangle
with open("svg_file.svg", "x") as f:
f.write("""""")
path = manim.SVGMobject("svg_file.svg", z_index=2, fill_color=manim.RED).move_to(rect.get_top())
self.add(path) # displayed incorrectly behind the rectangle
```

This was created with manim 0.17.2
Contributor guide
Research direction
Start by running the provided Test scene with svg_file.svg and compare the z_index behavior of Rectangle, Dot, Text, and SVGMobject. Trace the rendering path for SVGMobject and its Text subclass; done means both render in front of the rectangle when their z_index is higher.
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
- Clearly specified
- Newbie friendliness
- 48/100