Circle(圆)

完整名称:manim.mobject.geometry.arc.Circle

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

基类: Arc

一个圆。

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

  • kwargs (Any) – 传递给 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(环绕)

修改一个圆,使其环绕给定的 mobject。

属性

animate (动画)

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

animation_overrides (动画覆盖)

颜色

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

参数:
返回类型:

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

返回通过指定三点的圆。

示例

示例: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)

参数:
返回类型:

Circle(圆)

point_at_angle(angle)[source]

返回圆上某点的位置。

参数:

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

返回:

圆周上点的位置。

返回类型:

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]

修改一个圆,使其环绕给定的 mobject。

参数:
  • mobject (Mobject) – 圆将环绕的 mobject。

  • dim_to_match (int)

  • buffer_factor (float) – 相对于 mobject 缩放圆。小于 1 的 buffer_factor 会使圆小于 mobject。

  • stretch (bool) – 伸展圆以更紧密地贴合 mobject。注意:不适用于 Line

返回类型:

自身

示例

示例: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)