mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Ensure background rectangle matches orientation
This commit is contained in:
parent
f0df5c759d
commit
98eccab977
1 changed files with 13 additions and 0 deletions
|
@ -142,6 +142,19 @@ class VMobject(Mobject):
|
||||||
raise Exception("All submobjects must be of type VMobject")
|
raise Exception("All submobjects must be of type VMobject")
|
||||||
super().add(*vmobjects)
|
super().add(*vmobjects)
|
||||||
|
|
||||||
|
def add_background_rectangle(
|
||||||
|
self,
|
||||||
|
color: ManimColor | None = None,
|
||||||
|
opacity: float = 0.75,
|
||||||
|
**kwargs
|
||||||
|
):
|
||||||
|
normal = self.family_members_with_points()[0].get_unit_normal()
|
||||||
|
super().add_background_rectangle(color, opacity, **kwargs)
|
||||||
|
rect = self.background_rectangle
|
||||||
|
if np.dot(rect.get_unit_normal(), normal) < 0:
|
||||||
|
rect.reverse_points()
|
||||||
|
return self
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
def init_colors(self):
|
def init_colors(self):
|
||||||
self.set_fill(
|
self.set_fill(
|
||||||
|
|
Loading…
Add table
Reference in a new issue