API 参考:几何图形(geometry)

共 57 个类,按字母排序。每个类含中文说明、继承链、参数表与上手示例,API 文档由 autodoc 从 manim v0.21.0 源码自动生成;带完整中文精讲的类见 API 索引。

Angle

两条线的夹角图形:自动找交点、按半径画出夹角弧,可标注度数,几何作图必备。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Angle Angle VMobject->Angle

参数

line1

—,Line

line2

—,Line

radius

None,float | None

quadrant

(1, 1),AngleQuadrant

other_angle

False,bool

dot

False,bool

dot_radius

None,float | None

dot_distance

0.55,float

dot_color

ManimColor('#FFFFFF'),ParsableManimColor

elbow

False,bool

快速上手

angle = Angle(line1, line2, radius=0.5)

API 文档

class manim.Angle(line1: Line, line2: Line, radius: float | None = None, quadrant: AngleQuadrant = (1, 1), other_angle: bool = False, dot: bool = False, dot_radius: float | None = None, dot_distance: float = 0.55, dot_color: ParsableManimColor = ManimColor('#FFFFFF'), elbow: bool = False, **kwargs: Any)

基类:VMobject

static from_three_points(A: Point3DLike, B: Point3DLike, C: Point3DLike, **kwargs: Any) → Angle

The angle between the lines AB and BC.

This constructs the angle \(\\angle ABC\).

Parameters

A

The endpoint of the first angle leg

B

The vertex of the angle

C

The endpoint of the second angle leg

**kwargs

Further keyword arguments are passed to Angle

Returns

The Angle calculated from the three points

Angle(line1, line2, radius=0.5, quadrant=(-1,1), stroke_width=8), Angle(line1, line2, radius=0.7, quadrant=(-1,-1), color=RED, other_angle=True),

Examples

class AngleFromThreePointsExample(Scene):
    def construct(self):
        sample_angle = Angle.from_three_points(UP, ORIGIN, LEFT)
        red_angle = Angle.from_three_points(LEFT + UP, ORIGIN, RIGHT, radius=.8, quadrant=(-1,-1), color=RED, stroke_width=8, other_angle=True)
        self.add(red_angle, sample_angle)
get_lines() → VGroup

Get the lines forming an angle of the Angle class.

Returns

VGroup

A VGroup containing the lines that form the angle of the Angle class.

Examples

>>> line_1, line_2 = Line(ORIGIN, RIGHT), Line(ORIGIN, UR)
>>> angle = Angle(line_1, line_2)
>>> angle.get_lines()
VGroup(Line, Line)
get_value(degrees: bool = False) → float

Get the value of an angle of the Angle class.

Parameters

degrees

A boolean to decide the unit (deg/rad) in which the value of the angle is returned.

Returns

float

The value in degrees/radians of an angle of the Angle class.

Examples

class GetValueExample(Scene):
    def construct(self):
        line1 = Line(LEFT+(1/3)*UP, RIGHT+(1/3)*DOWN)
        line2 = Line(DOWN+(1/3)*RIGHT, UP+(1/3)*LEFT)

        angle = Angle(line1, line2, radius=0.4)

        value = DecimalNumber(angle.get_value(degrees=True), unit=r"^{\circ}")
        value.next_to(angle, UR)

        self.add(line1, line2, angle, value)

AnnotationDot

带描边强调的小圆点,比普通 Dot 在复杂背景上更醒目,常用于标记点。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle Dot Dot Circle->Dot AnnotationDot AnnotationDot Dot->AnnotationDot

参数

radius

0.10400000000000001,float

stroke_width

5,float

stroke_color

ManimColor('#FFFFFF'),ParsableManimColor

fill_color

ManimColor('#58C4DD'),ParsableManimColor

API 文档

class manim.AnnotationDot(radius: float = 0.10400000000000001, stroke_width: float = 5, stroke_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FFFFFF'), fill_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#58C4DD'), **kwargs: Any)

基类:Dot

AnnularSector

扇环(圆环的一段):内外半径 + 起止角度,饼图环图的基础件。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc AnnularSector AnnularSector Arc->AnnularSector

参数

inner_radius

1,float

outer_radius

2,float

angle

1.5707963267948966,float

start_angle

0,float

fill_opacity

1,float

stroke_width

0,float

color

ManimColor('#FFFFFF'),ParsableManimColor

快速上手

s = AnnularSector(inner_radius=1, outer_radius=2, angle=PI/2)

API 文档

class manim.AnnularSector(inner_radius: float = 1, outer_radius: float = 2, angle: float = 1.5707963267948966, start_angle: float = 0, fill_opacity: float = 1, stroke_width: float = 0, color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FFFFFF'), **kwargs: Any)

基类:Arc

generate_points() → Self

Initializes points and therefore the shape.

Gets called upon creation. This is an empty method that can be implemented by subclasses.

Annulus

完整圆环:内半径 + 外半径,甜甜圈形状。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle Annulus Annulus Circle->Annulus

参数

inner_radius

1,float

outer_radius

2,float

fill_opacity

1,float

stroke_width

0,float

color

ManimColor('#FFFFFF'),ParsableManimColor

mark_paths_closed

False,bool

API 文档

class manim.Annulus(inner_radius: float = 1, outer_radius: float = 2, fill_opacity: float = 1, stroke_width: float = 0, color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FFFFFF'), mark_paths_closed: bool = False, **kwargs: Any)

基类:Circle

generate_points() → Self

Initializes points and therefore the shape.

Gets called upon creation. This is an empty method that can be implemented by subclasses.

Arc

圆弧:半径 + 起始角 + 张角,所有曲线类图形(Circle、Sector……)的祖宗。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc

参数

radius

1.0,float | None

start_angle

0,float

angle

1.5707963267948966,float

num_components

9,int

arc_center

array([0., 0., 0.]),Point3DLike

快速上手

arc = Arc(radius=2, start_angle=0, angle=PI)

API 文档

class manim.Arc(radius: float | None = 1.0, start_angle: float = 0, angle: float = 1.5707963267948966, num_components: int = 9, arc_center: Point3DLike = array([0., 0., 0.]), **kwargs: Any)

基类:TipableVMobject

generate_points() → Self

Initializes points and therefore the shape.

Gets called upon creation. This is an empty method that can be implemented by subclasses.

get_arc_center(warning: bool = True) → Point3D

Looks at the normals to the first two anchors, and finds their intersection points

ArcBetweenPoints

过两点的一段圆弧:自动选半径让弧经过两点,画「连接箭头」或「跳跃路径」常用。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc ArcBetweenPoints ArcBetweenPoints Arc->ArcBetweenPoints

参数

start

—,Point3DLike

end

—,Point3DLike

angle

1.5707963267948966,float

radius

None,float | None

快速上手

arc = ArcBetweenPoints(a.get_center(), b.get_center())

API 文档

class manim.ArcBetweenPoints(start: Point3DLike, end: Point3DLike, angle: float = 1.5707963267948966, radius: float | None = None, **kwargs: Any)

基类:Arc

ArcPolygon

边为圆弧的多边形:顶点之间用弧连接而非直线,呈现「鼓包」轮廓。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject ArcPolygon ArcPolygon VMobject->ArcPolygon

参数

angle

0.7853981633974483,float

radius

None,float | None

arc_config

None,list[dict] | None

API 文档

class manim.ArcPolygon(*vertices: Point3DLike, angle: float = 0.7853981633974483, radius: float | None = None, arc_config: list[dict] | None = None, **kwargs: Any)

基类:VMobject

ArcPolygonFromArcs

用现成 Arc 对象拼成多边形,边完全由你给的弧决定。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject ArcPolygonFromArcs ArcPolygonFromArcs VMobject->ArcPolygonFromArcs

API 文档

class manim.ArcPolygonFromArcs(*arcs: Arc | ArcBetweenPoints, **kwargs: Any)

基类:VMobject

Arrow

带箭头的直线:start/end + 箭尖样式 buff 可调,是最常用的指向性图形。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line Arrow Arrow Line->Arrow

参数

stroke_width

6,float

buff

0.25,float

max_tip_length_to_length_ratio

0.25,float

max_stroke_width_to_length_ratio

5,float

快速上手

arrow = Arrow(LEFT, RIGHT, buff=0.1)

API 文档

class manim.Arrow(*args: Any, stroke_width: float = 6, buff: float = 0.25, max_tip_length_to_length_ratio: float = 0.25, max_stroke_width_to_length_ratio: float = 5, **kwargs: Any)

基类:Line

get_default_tip_length() → float

Returns the default tip_length of the arrow.

Examples

>>> Arrow().get_default_tip_length()
0.35
get_normal_vector() → Vector3D

Returns the normal of a vector.

Examples

>>> np.round(Arrow().get_normal_vector()) + 0. # add 0. to avoid negative 0 in output
array([ 0.,  0., -1.])
reset_normal_vector() → Self

Resets the normal of a vector

scale(factor: float, scale_tips: bool = False, **kwargs: Any) → Self

Scale an arrow, but keep stroke width and arrow tip size fixed.

参见

scale()

Examples

>>> arrow = Arrow(np.array([-1, -1, 0]), np.array([1, 1, 0]), buff=0)
>>> scaled_arrow = arrow.scale(2)
>>> np.round(scaled_arrow.get_start_and_end(), 8) + 0
array([[-2., -2.,  0.],
       [ 2.,  2.,  0.]])
>>> arrow.tip.length == scaled_arrow.tip.length
True

Manually scaling the object using the default method scale() does not have the same properties:

>>> new_arrow = Arrow(np.array([-1, -1, 0]), np.array([1, 1, 0]), buff=0)
>>> another_scaled_arrow = VMobject.scale(new_arrow, 2)
>>> another_scaled_arrow.tip.length == arrow.tip.length
False

ArrowCircleFilledTip

圆形实心箭尖样式类:配合 Arrow 的 tip_shape 使用(ArrowCircleTip 的实心版)。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle ArrowTip ArrowTip Circle->ArrowTip ArrowCircleTip ArrowCircleTip ArrowTip->ArrowCircleTip ArrowCircleFilledTip ArrowCircleFilledTip ArrowCircleTip->ArrowCircleFilledTip

参数

fill_opacity

1,float

stroke_width

0,float

API 文档

class manim.ArrowCircleFilledTip(fill_opacity: float = 1, stroke_width: float = 0, **kwargs: Any)

基类:ArrowCircleTip

ArrowCircleTip

空心圆形箭尖样式类:把箭头末端换成小圆圈,思维导图风。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle ArrowTip ArrowTip Circle->ArrowTip ArrowCircleTip ArrowCircleTip ArrowTip->ArrowCircleTip

参数

fill_opacity

0,float

stroke_width

3,float

length

0.35,float

start_angle

3.141592653589793,float

API 文档

class manim.ArrowCircleTip(fill_opacity: float = 0, stroke_width: float = 3, length: float = 0.35, start_angle: float = 3.141592653589793, **kwargs: Any)

基类:ArrowTip, Circle

ArrowSquareFilledTip

方形实心箭尖样式类。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Rectangle Rectangle Polygon->Rectangle Square Square Rectangle->Square ArrowTip ArrowTip Square->ArrowTip ArrowSquareTip ArrowSquareTip ArrowTip->ArrowSquareTip ArrowSquareFilledTip ArrowSquareFilledTip ArrowSquareTip->ArrowSquareFilledTip

参数

fill_opacity

1,float

stroke_width

0,float

API 文档

class manim.ArrowSquareFilledTip(fill_opacity: float = 1, stroke_width: float = 0, **kwargs: Any)

基类:ArrowSquareTip

ArrowSquareTip

空心方形箭尖样式类。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Rectangle Rectangle Polygon->Rectangle Square Square Rectangle->Square ArrowTip ArrowTip Square->ArrowTip ArrowSquareTip ArrowSquareTip ArrowTip->ArrowSquareTip

参数

fill_opacity

0,float

stroke_width

3,float

length

0.35,float

start_angle

3.141592653589793,float

API 文档

class manim.ArrowSquareTip(fill_opacity: float = 0, stroke_width: float = 3, length: float = 0.35, start_angle: float = 3.141592653589793, **kwargs: Any)

基类:ArrowTip, Square

ArrowTip

所有箭尖样式的基类:自定义箭尖就继承它实现 set_points(),length/width 属性定义尺寸。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject ArrowTip ArrowTip VMobject->ArrowTip

API 文档

class manim.ArrowTip(*args: Any, **kwargs: Any)

基类:VMobject

property base: Point3D

The base point of the arrow tip.

This is the point connecting to the arrow line.

Examples

>>> from manim import Arrow
>>> arrow = Arrow(np.array([0, 0, 0]), np.array([2, 0, 0]), buff=0)
>>> arrow.tip.base.round(2) + 0.  # add 0. to avoid negative 0 in output
array([1.65, 0.  , 0.  ])
property length: float

The length of the arrow tip.

Examples

>>> from manim import Arrow
>>> arrow = Arrow(np.array([0, 0, 0]), np.array([1, 2, 0]))
>>> round(arrow.tip.length, 3)
0.35
property tip_angle: float

The angle of the arrow tip.

Examples

>>> from manim import Arrow
>>> arrow = Arrow(np.array([0, 0, 0]), np.array([1, 1, 0]), buff=0)
>>> bool(round(arrow.tip.tip_angle, 5) == round(PI/4, 5))
True
property tip_point: Point3D

The tip point of the arrow tip.

Examples

>>> from manim import Arrow
>>> arrow = Arrow(np.array([0, 0, 0]), np.array([2, 0, 0]), buff=0)
>>> arrow.tip.tip_point.round(2) + 0.
array([2., 0., 0.])
property vector: Vector3D

The vector pointing from the base point to the tip point.

Examples

>>> from manim import Arrow
>>> arrow = Arrow(np.array([0, 0, 0]), np.array([2, 2, 0]), buff=0)
>>> arrow.tip.vector.round(2) + 0.
array([0.25, 0.25, 0.  ])

ArrowTriangleFilledTip

三角实心箭尖(默认样式),一般不直接实例化。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram RegularPolygram RegularPolygram Polygram->RegularPolygram RegularPolygon RegularPolygon RegularPolygram->RegularPolygon Triangle Triangle RegularPolygon->Triangle ArrowTip ArrowTip Triangle->ArrowTip ArrowTriangleTip ArrowTriangleTip ArrowTip->ArrowTriangleTip ArrowTriangleFilledTip ArrowTriangleFilledTip ArrowTriangleTip->ArrowTriangleFilledTip

参数

fill_opacity

1,float

stroke_width

0,float

API 文档

class manim.ArrowTriangleFilledTip(fill_opacity: float = 1, stroke_width: float = 0, **kwargs: Any)

基类:ArrowTriangleTip

ArrowTriangleTip

空心三角箭尖样式类。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram RegularPolygram RegularPolygram Polygram->RegularPolygram RegularPolygon RegularPolygon RegularPolygram->RegularPolygon Triangle Triangle RegularPolygon->Triangle ArrowTip ArrowTip Triangle->ArrowTip ArrowTriangleTip ArrowTriangleTip ArrowTip->ArrowTriangleTip

参数

fill_opacity

0,float

stroke_width

3,float

length

0.35,float

width

0.35,float

start_angle

3.141592653589793,float

API 文档

class manim.ArrowTriangleTip(fill_opacity: float = 0, stroke_width: float = 3, length: float = 0.35, width: float = 0.35, start_angle: float = 3.141592653589793, **kwargs: Any)

基类:ArrowTip, Triangle

BackgroundRectangle

自动包裹目标对象的背景色矩形:给文字图形加底色衬垫,防止与背景混淆。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Rectangle Rectangle Polygon->Rectangle RoundedRectangle RoundedRectangle Rectangle->RoundedRectangle SurroundingRectangle SurroundingRectangle RoundedRectangle->SurroundingRectangle BackgroundRectangle BackgroundRectangle SurroundingRectangle->BackgroundRectangle

参数

color

None

stroke_width

0,float

stroke_opacity

0,float

fill_opacity

0.75,float

buff

0

快速上手

bg = BackgroundRectangle(label, fill_opacity=0.7)

API 文档

class manim.BackgroundRectangle(*mobjects: Mobject, color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | None = None, stroke_width: float = 0, stroke_opacity: float = 0, fill_opacity: float = 0.75, buff: float | tuple[float, float] = 0, **kwargs: Any)

基类:SurroundingRectangle

pointwise_become_partial(mobject: Mobject, a: Any, b: float) → Self

Given a 2nd VMobject vmobject, a lower bound a and an upper bound b, modify this VMobject's points to match the portion of the Bézier spline described by vmobject.points with the parameter t between a and b.

Parameters

vmobject

The VMobject that will serve as a model.

a

The lower bound for t.

b

The upper bound for t

Returns

VMobject

The VMobject itself, after the transformation.

Raises

TypeError

If vmobject is not an instance of VMobject.

Circle

圆:radius 或 diameter 指定大小,提供 from_three_points、point_at_angle、surround 等几何工厂方法。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle

参数

radius

None,float | None

color

ManimColor('#FC6255'),ParsableManimColor

快速上手

c = Circle(radius=2, color=BLUE)

API 文档

class manim.Circle(radius: float | None = None, color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FC6255'), **kwargs: Any)

基类:Arc

static from_three_points(p1: Point3DLike, p2: Point3DLike, p3: Point3DLike, **kwargs: Any) → Circle

Returns a circle passing through the specified three points.

Example

class CircleFromPointsExample(Scene):
    def construct(self):
        circle = Circle.from_three_points(LEFT, LEFT + UP, UP * 2, color=RED)
        dots = VGroup(
            Dot(LEFT),
            Dot(LEFT + UP),
            Dot(UP * 2),
        )
        self.add(NumberPlane(), circle, dots)
point_at_angle(angle: float) → Point3D

Returns the position of a point on the circle.

Parameters

angle

The angle of the point along the circle in radians.

Returns

numpy.ndarray

The location of the point along the circle's circumference.

Examples

class PointAtAngleExample(Scene):
    def construct(self):
        circle = Circle(radius=2.0)
        p1 = circle.point_at_angle(PI/2)
        p2 = circle.point_at_angle(270*DEGREES)

        s1 = Square(side_length=0.25).move_to(p1)
        s2 = Square(side_length=0.25).move_to(p2)
        self.add(circle, s1, s2)
surround(mobject: Mobject, dim_to_match: int = 0, stretch: bool = False, buffer_factor: float = 1.2) → Self

Modifies a circle so that it surrounds a given mobject.

Parameters

mobject

The mobject that the circle will be surrounding.

dim_to_match buffer_factor

Scales the circle with respect to the mobject. A buffer_factor < 1 makes the circle smaller than the mobject.

stretch

Stretches the circle to fit more tightly around the mobject. Note: Does not work with Line

Examples

class CircleSurround(Scene):
    def construct(self):
        triangle1 = Triangle()
        circle1 = Circle().surround(triangle1)
        group1 = Group(triangle1,circle1) # treat the two mobjects as one

        line2 = Line()
        circle2 = Circle().surround(line2, buffer_factor=2.0)
        group2 = Group(line2,circle2)

        # buffer_factor < 1, so the circle is smaller than the square
        square3 = Square()
        circle3 = Circle().surround(square3, buffer_factor=0.5)
        group3 = Group(square3, circle3)

        group = Group(group1, group2, group3).arrange(buff=1)
        self.add(group)

ConvexHull

一组点的凸包多边形:自动计算外轮廓,计算几何可视化。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram ConvexHull ConvexHull Polygram->ConvexHull

参数

API 文档

class manim.ConvexHull(*points: Point3DLike, tolerance: float = 1e-05, **kwargs: Any)

基类:Polygram

Cross

叉号(×)图形:stroke_width 和比例可调,标记错误或否定语义。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject VGroup VGroup VMobject->VGroup Cross Cross VGroup->Cross

参数

mobject

None,Mobject | None

stroke_color

ManimColor('#FC6255'),ParsableManimColor

stroke_width

6.0,float

scale_factor

1.0,float

快速上手

cross = Cross(mob)

API 文档

class manim.Cross(mobject: Mobject | None = None, stroke_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FC6255'), stroke_width: float = 6.0, scale_factor: float = 1.0, **kwargs: Any)

基类:VGroup

CubicBezier

三次贝塞尔曲线:两个锚点 + 两个控制点,是矢量绘图的最小单元。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject CubicBezier CubicBezier VMobject->CubicBezier

参数

start_anchor

—,Point3DLike

start_handle

—,Point3DLike

end_handle

—,Point3DLike

end_anchor

—,Point3DLike

快速上手

b = CubicBezier(a1, h1, h2, a2)

API 文档

class manim.CubicBezier(start_anchor: Point3DLike, start_handle: Point3DLike, end_handle: Point3DLike, end_anchor: Point3DLike, **kwargs: Any)

基类:VMobject

CurvedArrow

弯曲的箭头:ArcBetweenPoints + 箭尖的组合体,流程图里绕过障碍的连线。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc ArcBetweenPoints ArcBetweenPoints Arc->ArcBetweenPoints CurvedArrow CurvedArrow ArcBetweenPoints->CurvedArrow

参数

start_point

—,Point3DLike

end_point

—,Point3DLike

API 文档

class manim.CurvedArrow(start_point: Point3DLike, end_point: Point3DLike, **kwargs: Any)

基类:ArcBetweenPoints

CurvedDoubleArrow

两端都带箭尖的弯弧,双向关系专用。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc ArcBetweenPoints ArcBetweenPoints Arc->ArcBetweenPoints CurvedArrow CurvedArrow ArcBetweenPoints->CurvedArrow CurvedDoubleArrow CurvedDoubleArrow CurvedArrow->CurvedDoubleArrow

参数

start_point

—,Point3DLike

end_point

—,Point3DLike

API 文档

class manim.CurvedDoubleArrow(start_point: Point3DLike, end_point: Point3DLike, **kwargs: Any)

基类:CurvedArrow

Cutout

带镂空的多边形:外部轮廓减内部孔洞,fill 模式下孔洞透明。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Cutout Cutout VMobject->Cutout

参数

快速上手

c = Cutout(square, circle)

API 文档

class manim.Cutout(main_shape: VMobject, *mobjects: VMobject, **kwargs: Any)

基类:VMobject

DashedLine

虚线直线:DashedVMobject 的直线便捷版,辅助线首选。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line DashedLine DashedLine Line->DashedLine

参数

dash_length

0.05,float

dashed_ratio

0.5,float

快速上手

d = DashedLine(LEFT, RIGHT)

API 文档

class manim.DashedLine(*args: Any, dash_length: float = 0.05, dashed_ratio: float = 0.5, **kwargs: Any)

基类:Line

get_end() → Point3D

Returns the end point of the line.

Examples

>>> DashedLine().get_end()
array([1., 0., 0.])
get_first_handle() → Point3D

Returns the point of the first handle.

Examples

>>> DashedLine().get_first_handle()
array([-0.98333333,  0.        ,  0.        ])
get_last_handle() → Point3D

Returns the point of the last handle.

Examples

>>> DashedLine().get_last_handle()
array([0.98333333, 0.        , 0.        ])
get_start() → Point3D

Returns the start point of the line.

Examples

>>> DashedLine().get_start()
array([-1.,  0.,  0.])

Difference

布尔差集:从主体图形中挖掉重叠部分,属于 VMobject 布尔运算家族。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Difference Difference VMobject->Difference

参数

subject

—,VMobject

clip

—,VMobject

快速上手

diff = Difference(square, circle)

API 文档

class manim.Difference(subject: VMobject, clip: VMobject, **kwargs: Any)

基类:_BooleanOps

Dot

小圆点:radius 很小且 fill 为主,标记坐标、描点画图的基本单元。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle Dot Dot Circle->Dot

参数

point

array([0., 0., 0.]),Point3DLike

radius

0.08,float

stroke_width

0,float

fill_opacity

1.0,float

color

ManimColor('#FFFFFF'),ParsableManimColor

快速上手

dot = Dot(point, color=RED)

API 文档

class manim.Dot(point: Point3DLike = array([0., 0., 0.]), radius: float = 0.08, stroke_width: float = 0, fill_opacity: float = 1.0, color: ParsableManimColor = ManimColor('#FFFFFF'), **kwargs: Any)

基类:Circle

DoubleArrow

两端都有箭头的直线,表示双向映射或区间。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line Arrow Arrow Line->Arrow DoubleArrow DoubleArrow Arrow->DoubleArrow

快速上手

d = DoubleArrow(LEFT, RIGHT)

API 文档

class manim.DoubleArrow(*args: Any, **kwargs: Any)

基类:Arrow

Elbow

直角弯头线:两条垂直短线段,管道图、直角坐标标记用。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Elbow Elbow VMobject->Elbow

参数

width

0.2,float

angle

0,float

API 文档

class manim.Elbow(width: float = 0.2, angle: float = 0, **kwargs: Any)

基类:VMobject

Ellipse

椭圆:width/height 分别指定两轴,圆形的长轴版。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle Ellipse Ellipse Circle->Ellipse

参数

width

2,float

height

1,float

快速上手

e = Ellipse(width=4, height=2)

API 文档

class manim.Ellipse(width: float = 2, height: float = 1, **kwargs: Any)

基类:Circle

Exclusion

布尔异或:只保留两个图形不重叠的部分。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Exclusion Exclusion VMobject->Exclusion

参数

subject

—,VMobject

clip

—,VMobject

API 文档

class manim.Exclusion(subject: VMobject, clip: VMobject, **kwargs: Any)

基类:_BooleanOps

Intersection

布尔交集:只保留两个图形重叠的区域。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Intersection Intersection VMobject->Intersection

快速上手

i = Intersection(square, circle)

API 文档

class manim.Intersection(*vmobjects: VMobject, **kwargs: Any)

基类:_BooleanOps

Label

几何图形上的标签:自带背景框的小文本,跟随目标位置摆放。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject VGroup VGroup VMobject->VGroup Label Label VGroup->Label

参数

label

—,str | ManimTextLabel

label_config

None,dict[str, Any] | None

box_config

None,dict[str, Any] | None

frame_config

None,dict[str, Any] | None

API 文档

class manim.Label(label: str | ManimTextLabel, label_config: dict[str, Any] | None = None, box_config: dict[str, Any] | None = None, frame_config: dict[str, Any] | None = None, **kwargs: Any)

基类:VGroup

LabeledArrow

带文字标签的箭头:label 自动置于箭身中点,省去手动对位。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line Arrow Arrow Line->Arrow LabeledLine LabeledLine Arrow->LabeledLine LabeledArrow LabeledArrow LabeledLine->LabeledArrow

API 文档

class manim.LabeledArrow(*args: Any, **kwargs: Any)

基类:LabeledLine, Arrow

LabeledDot

带文字标签的圆点:标签居中于点内,图论顶点标注专用。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc Circle Circle Arc->Circle Dot Dot Circle->Dot LabeledDot LabeledDot Dot->LabeledDot

参数

label

—

radius

None,float | None

buff

0.1,float

API 文档

class manim.LabeledDot(label: str | SingleStringMathTex | Text | Tex, radius: float | None = None, buff: float = 0.1, **kwargs: Any)

基类:Dot

LabeledLine

带标签的直线:标签自动放在线段中点。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line LabeledLine LabeledLine Line->LabeledLine

参数

label

—,str | ManimTextLabel

label_position

0.5,float

label_config

None,dict[str, Any] | None

box_config

None,dict[str, Any] | None

frame_config

None,dict[str, Any] | None

API 文档

class manim.LabeledLine(label: str | ManimTextLabel, label_position: float = 0.5, label_config: dict[str, Any] | None = None, box_config: dict[str, Any] | None = None, frame_config: dict[str, Any] | None = None, *args: Any, **kwargs: Any)

基类:Line

LabeledPolygram

带顶点标签的折线/多边形:每个顶点自动编号。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram LabeledPolygram LabeledPolygram Polygram->LabeledPolygram

参数

label

—,str | ManimTextLabel

precision

0.01,float

label_config

None,dict[str, Any] | None

box_config

None,dict[str, Any] | None

frame_config

None,dict[str, Any] | None

API 文档

class manim.LabeledPolygram(*vertex_groups: Point3DLike_Array, label: str | ManimTextLabel, precision: float = 0.01, label_config: dict[str, Any] | None = None, box_config: dict[str, Any] | None = None, frame_config: dict[str, Any] | None = None, **kwargs: Any)

基类:Polygram

Line

两点之间的直线:buff 让端点留白不压对象,put_start_and_end_on 可动画化,是构图的骨架。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line

参数

start

array([-1., 0., 0.]),Point3DLike | Mobject

end

array([1., 0., 0.]),Point3DLike | Mobject

buff

0,float

path_arc

0,float

快速上手

line = Line(ORIGIN, RIGHT * 3)

API 文档

class manim.Line(start: Point3DLike | Mobject = array([-1., 0., 0.]), end: Point3DLike | Mobject = array([1., 0., 0.]), buff: float = 0, path_arc: float = 0, **kwargs: Any)

基类:TipableVMobject

generate_points() → Self

Initializes points and therefore the shape.

Gets called upon creation. This is an empty method that can be implemented by subclasses.

get_projection(point: Point3DLike) → Point3D

Returns the projection of a point onto a line.

Parameters

point

The point to which the line is projected.

put_start_and_end_on(start: Point3DLike, end: Point3DLike) → Self

Sets starts and end coordinates of a line.

Examples

class LineExample(Scene):
    def construct(self):
        d = VGroup()
        for i in range(0,10):
            d.add(Dot())
        d.arrange_in_grid(buff=1)
        self.add(d)
        l= Line(d[0], d[1])
        self.add(l)
        self.wait()
        l.put_start_and_end_on(d[1].get_center(), d[2].get_center())
        self.wait()
        l.put_start_and_end_on(d[4].get_center(), d[7].get_center())
        self.wait()
set_points_by_ends(start: Point3DLike | Mobject, end: Point3DLike | Mobject, buff: float = 0, path_arc: float = 0) → Self

Sets the points of the line based on its start and end points. Unlike put_start_and_end_on(), this method respects self.buff and Mobject bounding boxes.

Parameters

start

The start point or Mobject of the line.

end

The end point or Mobject of the line.

buff

The empty space between the start and end of the line, by default 0.

path_arc

The angle of a circle spanned by this arc, by default 0 which is a straight line.

Polygon

多边形:顶点列表连线闭合,一切直边图形(三角形、矩形……)的基类。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon

快速上手

p = Polygon(ORIGIN, RIGHT, UP)

API 文档

class manim.Polygon(*vertices: Point3DLike, **kwargs: Any)

基类:Polygram

Polygram

折线组:可以含多个不闭合顶点组(组 = 一条折线),比 Polygon 更自由的连点工具。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram

参数

API 文档

class manim.Polygram(*vertex_groups: Point3DLike_Array, color: ParsableManimColor = ManimColor('#58C4DD'), **kwargs: Any)

基类:VMobject

get_vertex_groups() → list[Point3D_Array]

Gets the vertex groups of the Polygram.

Returns

list[Point3D_Array]

The list of vertex groups of the Polygram.

Examples

>>> poly = Polygram([ORIGIN, RIGHT, UP, LEFT + UP], [LEFT, LEFT + UP, 2 * LEFT])
>>> groups = poly.get_vertex_groups()
>>> len(groups)
2
>>> groups[0]
array([[ 0.,  0.,  0.],
       [ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [-1.,  1.,  0.]])
>>> groups[1]
array([[-1.,  0.,  0.],
       [-1.,  1.,  0.],
       [-2.,  0.,  0.]])
get_vertices() → Point3D_Array

Gets the vertices of the Polygram.

Returns

numpy.ndarray

The vertices of the Polygram.

Examples

>>> sq = Square()
>>> sq.get_vertices()
array([[ 1.,  1.,  0.],
       [-1.,  1.,  0.],
       [-1., -1.,  0.],
       [ 1., -1.,  0.]])
round_corners(radius: float | list[float] = 0.5, evenly_distribute_anchors: bool = False, components_per_rounded_corner: int = 2) → Self

Rounds off the corners of the Polygram.

Parameters

radius

The curvature of the corners of the Polygram.

evenly_distribute_anchors

Break long line segments into proportionally-sized segments.

components_per_rounded_corner

The number of points used to represent the rounded corner curve.

参见

RoundedRectangle

备注

If radius is supplied as a single value, then the same radius will be applied to all corners. If radius is a list, then the individual values will be applied sequentially, with the first corner receiving radius[0], the second corner receiving radius[1], etc. The radius list will be repeated as necessary.

The components_per_rounded_corner value is provided so that the fidelity of the rounded corner may be fine-tuned as needed. 2 is an appropriate value for most shapes, however a larger value may be need if the rounded corner is particularly large. 2 is the minimum number allowed, representing the start and end of the curve. 3 will result in a start, middle, and end point, meaning 2 curves will be generated.

The option to evenly_distribute_anchors is provided so that the line segments (the part part of each line remaining after rounding off the corners) can be subdivided to a density similar to that of the average density of the rounded corners. This may be desirable in situations in which an even distribution of curves is desired for use in later transformation animations. Be aware, though, that enabling this option can result in an an object containing significantly more points than the original, especially when the rounded corner curves are small.

Examples

class PolygramRoundCorners(Scene):
    def construct(self):
        star = Star(outer_radius=2)

        shapes = VGroup(star)
        shapes.add(star.copy().round_corners(radius=0.1))
        shapes.add(star.copy().round_corners(radius=0.25))

        shapes.arrange(RIGHT)
        self.add(shapes)

Rectangle

矩形:width/height 与角半径可调,包围、对齐、底衬的主力图形。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Rectangle Rectangle Polygon->Rectangle

参数

color

ManimColor('#FFFFFF'),ParsableManimColor

height

2.0,float

width

4.0,float

grid_xstep

None,float | None

grid_ystep

None,float | None

mark_paths_closed

True,bool

close_new_points

True,bool

快速上手

r = Rectangle(width=4, height=2)

API 文档

class manim.Rectangle(color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FFFFFF'), height: float = 2.0, width: float = 4.0, grid_xstep: float | None = None, grid_ystep: float | None = None, mark_paths_closed: bool = True, close_new_points: bool = True, **kwargs: Any)

基类:Polygon

RegularPolygon

正多边形:n 指定边数,内切圆半径可调。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram RegularPolygram RegularPolygram Polygram->RegularPolygram RegularPolygon RegularPolygon RegularPolygram->RegularPolygon

参数

快速上手

hexagon = RegularPolygon(n=6)

API 文档

class manim.RegularPolygon(n: int = 6, **kwargs: Any)

基类:RegularPolygram

RegularPolygram

正多角星:n 顶点按密度跳着连线(如五角星 density=2)。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram RegularPolygram RegularPolygram Polygram->RegularPolygram

参数

num_vertices

—,int

density

2,int

radius

1,float

start_angle

None,float | None

API 文档

class manim.RegularPolygram(num_vertices: int, *, density: int = 2, radius: float = 1, start_angle: float | None = None, **kwargs: Any)

基类:Polygram

RightAngle

直角标记:两条线垂直时的小方框角标,几何证明标配。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Angle Angle VMobject->Angle RightAngle RightAngle Angle->RightAngle

参数

line1

—,Line

line2

—,Line

length

None,float | None

快速上手

ra = RightAngle(line1, line2, length=0.3)

API 文档

class manim.RightAngle(line1: Line, line2: Line, length: float | None = None, **kwargs: Any)

基类:Angle

RoundedRectangle

圆角矩形:corner_radius 控制圆角,卡片式 UI 元素的首选。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Rectangle Rectangle Polygon->Rectangle RoundedRectangle RoundedRectangle Rectangle->RoundedRectangle

参数

快速上手

card = RoundedRectangle(corner_radius=0.2, width=4, height=2)

API 文档

class manim.RoundedRectangle(corner_radius: float | list[float] = 0.5, **kwargs: Any)

基类:Rectangle

Sector

扇形:圆 + 张角,饼图的组成单元。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc AnnularSector AnnularSector Arc->AnnularSector Sector Sector AnnularSector->Sector

参数

快速上手

s = Sector(angle=PI/3)

API 文档

class manim.Sector(radius: float = 1, **kwargs: Any)

基类:AnnularSector

Square

正方形:Rectangle 的等边便捷版,边长用 side_length。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Rectangle Rectangle Polygon->Rectangle Square Square Rectangle->Square

参数

快速上手

sq = Square(side_length=2)

API 文档

class manim.Square(side_length: float = 2.0, **kwargs: Any)

基类:Rectangle

Star

五角星样式的正多角星:n 与密度决定角数,外内半径比决定胖瘦。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Star Star Polygon->Star

参数

n

5,int

outer_radius

1,float

inner_radius

None,float | None

density

2,int

start_angle

1.5707963267948966,float | None

快速上手

star = Star(n=5, fill_color=YELLOW)

API 文档

class manim.Star(n: int = 5, *, outer_radius: float = 1, inner_radius: float | None = None, density: int = 2, start_angle: float | None = 1.5707963267948966, **kwargs: Any)

基类:Polygon

StealthTip

隐形战斗机风格的箭尖(默认箭尖),一般不直接实例化。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject ArrowTip ArrowTip VMobject->ArrowTip StealthTip StealthTip ArrowTip->StealthTip

参数

fill_opacity

1,float

stroke_width

3,float

length

0.175,float

start_angle

3.141592653589793,float

API 文档

class manim.StealthTip(fill_opacity: float = 1, stroke_width: float = 3, length: float = 0.175, start_angle: float = 3.141592653589793, **kwargs: Any)

基类:ArrowTip

property length: float

The length of the arrow tip.

In this case, the length is computed as the height of the triangle encompassing the stealth tip (otherwise, the tip is scaled too large).

SurroundingRectangle

围绕目标的矩形框:自动留边距包围对象,强调、圈选必备。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram Polygon Polygon Polygram->Polygon Rectangle Rectangle Polygon->Rectangle RoundedRectangle RoundedRectangle Rectangle->RoundedRectangle SurroundingRectangle SurroundingRectangle RoundedRectangle->SurroundingRectangle

参数

color

ManimColor('#FFFF00'),ParsableManimColor

buff

0.1

corner_radius

0.0,float

快速上手

box = SurroundingRectangle(formula, color=YELLOW)

API 文档

class manim.SurroundingRectangle(*mobjects: Mobject, color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FFFF00'), buff: float | tuple[float, float] = 0.1, corner_radius: float = 0.0, **kwargs: Any)

基类:RoundedRectangle

TangentLine

曲线在指定参数处的切线:微分几何可视化直接可用。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line TangentLine TangentLine Line->TangentLine

参数

vmob

—,VMobject

alpha

—,float

length

1,float

d_alpha

1e-06,float

快速上手

t = TangentLine(circle, alpha=0.3)

API 文档

class manim.TangentLine(vmob: VMobject, alpha: float, length: float = 1, d_alpha: float = 1e-06, **kwargs: Any)

基类:Line

TangentialArc

以一点为端点、与曲线相切的弧:强调方向变化的小装饰。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Arc Arc TipableVMobject->Arc ArcBetweenPoints ArcBetweenPoints Arc->ArcBetweenPoints TangentialArc TangentialArc ArcBetweenPoints->TangentialArc

参数

line1

—,Line

line2

—,Line

radius

—,float

corner

(1, 1),Any

API 文档

class manim.TangentialArc(line1: Line, line2: Line, radius: float, corner: Any = (1, 1), **kwargs: Any)

基类:ArcBetweenPoints

TipableVMobject

「可装箭尖」线段的基类:Arrow、Line 继承它获得 add_tip/tip 配置能力。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject

参数

tip_length

0.35,float

normal_vector

array([0., 0., 1.]),Vector3DLike

tip_style

None,dict | None

API 文档

class manim.TipableVMobject(tip_length: float = 0.35, normal_vector: Vector3DLike = array([0., 0., 1.]), tip_style: dict | None = None, **kwargs: Any)

基类:VMobject

add_tip(tip: tips.ArrowTip | None = None, tip_shape: type[tips.ArrowTip] | None = None, tip_length: float | None = None, tip_width: float | None = None, at_start: bool = False) → Self

Adds a tip to the TipableVMobject instance, recognising that the endpoints might need to be switched if it's a 'starting tip' or not.

create_tip(tip_shape: type[tips.ArrowTip] | None = None, tip_length: float | None = None, tip_width: float | None = None, at_start: bool = False) → tips.ArrowTip

Stylises the tip, positions it spatially, and returns the newly instantiated tip to the caller.

get_end() → Point3D

Returns the point, where the stroke that surrounds the Mobject ends.

get_start() → Point3D

Returns the point, where the stroke that surrounds the Mobject starts.

get_tip() → VMobject

Returns the TipableVMobject instance's (first) tip, otherwise throws an exception.

get_tips() → VGroup

Returns a VGroup (collection of VMobjects) containing the TipableVMObject instance's tips.

get_unpositioned_tip(tip_shape: type[tips.ArrowTip] | None = None, tip_length: float | None = None, tip_width: float | None = None) → tips.ArrowTip | tips.ArrowTriangleFilledTip

Returns a tip that has been stylistically configured, but has not yet been given a position in space.

Triangle

等边三角形:RegularPolygon(n=3) 的便捷版。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Polygram Polygram VMobject->Polygram RegularPolygram RegularPolygram Polygram->RegularPolygram RegularPolygon RegularPolygon RegularPolygram->RegularPolygon Triangle Triangle RegularPolygon->Triangle

快速上手

tri = Triangle()

API 文档

class manim.Triangle(**kwargs: Any)

基类:RegularPolygon

Underline

下划线:贴住目标底部的横线,强调文本用。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line Underline Underline Line->Underline

参数

mobject

—,Mobject

buff

0.1,float

快速上手

u = Underline(text)

API 文档

class manim.Underline(mobject: Mobject, buff: float = 0.1, **kwargs: Any)

基类:Line

Union

布尔并集:合并两个图形为一个轮廓。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject Union Union VMobject->Union

快速上手

u = Union(square, circle)

API 文档

class manim.Union(*vmobjects: VMobject, **kwargs: Any)

基类:_BooleanOps

Vector

从原点出发的箭头(向量):direction 与长度构造,线性代数可视化核心对象。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TipableVMobject TipableVMobject VMobject->TipableVMobject Line Line TipableVMobject->Line Arrow Arrow Line->Arrow Vector Vector Arrow->Vector

参数

direction

array([1., 0., 0.])

buff

0,float

快速上手

v = Vector(RIGHT * 2, color=RED)

API 文档

class manim.Vector(direction: Vector2DLike | Vector3DLike = array([1., 0., 0.]), buff: float = 0, **kwargs: Any)

基类:Arrow

coordinate_label(integer_labels: bool = True, n_dim: int = 2, color: ParsableManimColor | None = None, **kwargs: Any) → Matrix

Creates a label based on the coordinates of the vector.

Parameters

integer_labels

Whether or not to round the coordinates to integers.

n_dim

The number of dimensions of the vector.

color

Sets the color of label, optional.

kwargs

Additional arguments to be passed to Matrix.

Returns

Matrix

The label.

Examples

class VectorCoordinateLabel(Scene):
    def construct(self):
        plane = NumberPlane()

        vec_1 = Vector([1, 2])
        vec_2 = Vector([-3, -2])
        label_1 = vec_1.coordinate_label()
        label_2 = vec_2.coordinate_label(color=YELLOW)

        self.add(plane, vec_1, vec_2, label_1, label_2)