圆形

限定名称: manim.mobject.geometry.arc.Circle

class Circle(radius=None, color=ManimColor('#FC6255'), **kwargs)[来源]

基础类: Arc

一个圆。

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

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

  • radius (float | None)

示例

示例:CircleExample

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

class CircleExample(Scene):
    def construct(self):
        circle_1 = Circle(radius=1.0)
        circle_2 = Circle(radius=1.5, color=GREEN)
        circle_3 = Circle(radius=1.0, color=BLUE_B, fill_opacity=1)

        circle_group = Group(circle_1, circle_2, circle_3).arrange(buff=1)
        self.add(circle_group)
class CircleExample(Scene):
    def construct(self):
        circle_1 = Circle(radius=1.0)
        circle_2 = Circle(radius=1.5, color=GREEN)
        circle_3 = Circle(radius=1.0, color=BLUE_B, fill_opacity=1)

        circle_group = Group(circle_1, circle_2, circle_3).arrange(buff=1)
        self.add(circle_group)

方法

from_three_points

返回通过指定三个点的圆。

point_at_angle

返回圆上点的位置。

surround

修改一个圆,使其围绕给定的对象。

属性

animate

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

animation_overrides

color

depth

mobject的深度。

fill_color

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

height

mobject的高度。

n_points_per_curve

sheen_factor

stroke_color

width

mobject的宽度。

_original__init__(radius=None, color=ManimColor('#FC6255'), **kwargs)

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

Parameters:
Return type:

static from_three_points(p1, p2, p3, **kwargs)[来源]

返回通过指定三个点的圆。

示例

示例:CircleFromPointsExample

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

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)
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)

Parameters:
Return type:

自我

point_at_angle(angle)[source]

返回圆上点的位置。

Parameters:

angle (float) – 点在圆上的角度,以弧度表示。

Returns:

点在圆周上的位置。

Return type:

numpy.ndarray

示例

示例:PointAtAngleExample

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

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)
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, dim_to_match=0, stretch=False, buffer_factor=1.2)[source]

修改一个圆,使其围绕给定的对象。

Parameters:
  • mobject (Mobject) – 圆圈将围绕的mobject。

  • dim_to_match (int)

  • buffer_factor (float) – 相对于mobject缩放圆圈。一个buffer_factor < 1会使圆圈比mobject小。

  • stretch (bool) – 拉伸圆圈以更紧密地围绕mobject。注意:不适用于 Line

Return type:

自我

示例

示例:CircleSurround

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

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)
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)