Rectangle¶
完整名称: 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
一个具有两组平行边的四边形。
- 参数:
color (ParsableManimColor) – 矩形的颜色。
height (浮点数) – 矩形的垂直高度。
width (浮点数) – 矩形的水平宽度。
grid_xstep (浮点数 | None) – 垂直网格线之间的间距。
grid_ystep (浮点数 | None) – 水平网格线之间的间距。
mark_paths_closed (布尔值) – 无特定用途。
close_new_points (布尔值) – 无特定用途。
kwargs (任意类型) – 传递给
Polygon
的额外参数。
示例
示例:RectangleExample ¶
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 (动画覆盖)
颜色
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))。
- 参数:
color (ParsableManimColor)
高度 (浮点数)
宽度 (浮点数)
grid_xstep (浮点数 | None)
grid_ystep (浮点数 | None)
mark_paths_closed (布尔值)
close_new_points (布尔值)
kwargs (任意类型)