I'm starting with manim (Manim Community v0.17.1
) and I got behaviors that I can't explain on some very basic example, any help appreciated.
class SquareScene(Scene):
def construct(self):
kwargs = {"fill_opacity": 1, "stroke_color": WHITE}
square1 = Square(5, color=RED, grid_xstep=1, grid_ystep=1, **kwargs)
square2 = square1.copy().set(color=BLUE, **kwargs).shift(UP + RIGHT)
self.add(square2, square1)
square1
is displayed without a grid, I don't know whysquare2
does have a gridEDIT: I managed to solve the problem by setting fill_color=RED
instead of color=RED
. As I noticed the grid was there but also RED
hence not visible.
Still it doesn't explain why the BLUE
square grid color was WHITE
then..
Looking at how Square
processes grid_xstep
and grid_ystep
(see https://github.com/ManimCommunity/manim/blob/9efe81daa3e88e25244affd3700e2d2a8b527635/manim/mobject/geometry/polygram.py#L552-L581), I would actually consider this behavior a bug: the method only passes the color
keyword argument to the constructed Line
objects.
The construction of the lines also happens right at the end of the constructor; the color / fill color / stroke color of the parent mobject, the Square
, have already been set at that point. Setting them (again) after the mobject has been constructed then also properly handles the color of the grid lines.
Feel free to open a bug report over at https://github.com/ManimCommunity/manim!