BackgroundRectangle¶
Qualified name: manim.mobject.geometry.shape\_matchers.BackgroundRectangle
- class BackgroundRectangle(*mobjects, color=None, stroke_width=0, stroke_opacity=0, fill_opacity=0.75, buff=0, **kwargs)[source]¶
Bases:
SurroundingRectangleA background rectangle. Its default color is the background color of the scene.
Examples
Example: ExampleBackgroundRectangle ¶
from manim import * class ExampleBackgroundRectangle(Scene): def construct(self): circle = Circle().shift(LEFT) circle.set_stroke(color=GREEN, width=20) triangle = Triangle().shift(2 * RIGHT) triangle.set_fill(PINK, opacity=0.5) backgroundRectangle1 = BackgroundRectangle(circle, color=WHITE, fill_opacity=0.15) backgroundRectangle2 = BackgroundRectangle(triangle, color=WHITE, fill_opacity=0.15) self.add(backgroundRectangle1) self.add(backgroundRectangle2) self.add(circle) self.add(triangle) self.play(Rotate(backgroundRectangle1, PI / 4)) self.play(Rotate(backgroundRectangle2, PI / 2))
class ExampleBackgroundRectangle(Scene): def construct(self): circle = Circle().shift(LEFT) circle.set_stroke(color=GREEN, width=20) triangle = Triangle().shift(2 * RIGHT) triangle.set_fill(PINK, opacity=0.5) backgroundRectangle1 = BackgroundRectangle(circle, color=WHITE, fill_opacity=0.15) backgroundRectangle2 = BackgroundRectangle(triangle, color=WHITE, fill_opacity=0.15) self.add(backgroundRectangle1) self.add(backgroundRectangle2) self.add(circle) self.add(triangle) self.play(Rotate(backgroundRectangle1, PI / 4)) self.play(Rotate(backgroundRectangle2, PI / 2))Methods
Given a 2nd
VMobjectvmobject, a lower boundaand an upper boundb, modify thisVMobject's points to match the portion of the Bézier spline described byvmobject.pointswith the parametertbetweenaandb.set_styleAttributes
alwaysCall a method on a mobject every frame.
animateUsed to animate the application of any method of
self.animation_overridescolordepthThe depth of the mobject.
fill_colorIf there are multiple colors (for gradient) this returns the first one
heightThe height of the mobject.
n_points_per_curvesheen_factorstroke_colorwidthThe width of the mobject.
- Parameters:
mobjects (Mobject)
color (ParsableManimColor | None)
stroke_width (float)
stroke_opacity (float)
fill_opacity (float)
buff (float | tuple[float, float])
kwargs (Any)
- _original__init__(*mobjects, color=None, stroke_width=0, stroke_opacity=0, fill_opacity=0.75, buff=0, **kwargs)¶
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
mobjects (Mobject)
color (TypeAliasForwardRef('~manim.utils.color.core.ParsableManimColor') | None)
stroke_width (float)
stroke_opacity (float)
fill_opacity (float)
buff (float | tuple[float, float])
kwargs (Any)
- Return type:
None