矩形

限定名称: manim.mobject.geometry.polygram.Rectangle

class Rectangle(color=ManimColor('#FFFFFF'), height=2.0, width=4.0, grid_xstep=None, grid_ystep=None, mark_paths_closed=True, close_new_points=True, **kwargs)[来源]

基础类: Polygon

具有两组平行边的四边形。

Parameters:
  • color (ParsableManimColor) – 矩形的颜色。

  • height (float) – 矩形的垂直高度。

  • width (float) – 矩形的水平宽度。

  • grid_xstep (float | None) – 垂直网格线之间的间距。

  • grid_ystep (float | None) – 水平网格线之间的间距。

  • mark_paths_closed (bool) – 无用途。

  • close_new_points (bool) – 无用途。

  • kwargs – 传递给Polygon的额外参数

示例

示例:RectangleExample

../_images/RectangleExample-1.png
from manim import *

class RectangleExample(Scene):
    def construct(self):
        rect1 = Rectangle(width=4.0, height=2.0, grid_xstep=1.0, grid_ystep=0.5)
        rect2 = Rectangle(width=1.0, height=4.0)
        rect3 = Rectangle(width=2.0, height=2.0, grid_xstep=1.0, grid_ystep=1.0)
        rect3.grid_lines.set_stroke(width=1)

        rects = Group(rect1, rect2, rect3).arrange(buff=1)
        self.add(rects)
class RectangleExample(Scene):
    def construct(self):
        rect1 = Rectangle(width=4.0, height=2.0, grid_xstep=1.0, grid_ystep=0.5)
        rect2 = Rectangle(width=1.0, height=4.0)
        rect3 = Rectangle(width=2.0, height=2.0, grid_xstep=1.0, grid_ystep=1.0)
        rect3.grid_lines.set_stroke(width=1)

        rects = Group(rect1, rect2, rect3).arrange(buff=1)
        self.add(rects)

方法

属性

animate

用于动画化self的任何方法的应用。

animation_overrides

color

depth

mobject的深度。

fill_color

如果有多种颜色(用于渐变),则返回第一个颜色

height

mobject的高度。

n_points_per_curve

sheen_factor

stroke_color

width

mobject的宽度。

_original__init__(color=ManimColor('#FFFFFF'), height=2.0, width=4.0, grid_xstep=None, grid_ystep=None, mark_paths_closed=True, close_new_points=True, **kwargs)

初始化自身。有关准确的签名,请参阅 help(type(self))。

Parameters:
  • 颜色 (ParsableManimColor)

  • 高度 (浮点数)

  • width (float)

  • grid_xstep (float | None)

  • grid_ystep (float | None)

  • mark_paths_closed (bool)

  • close_new_points (bool)