1.圆 [Circle]
Circle(radius=None, color=ManimColor('#FC6255'))
在弧度的基础上出来的,具有两个参数:半径和弧线的颜色
2.实例01:
from manim import *
class CircleExample01(Scene):
def construct(self):
circle_1 = Circle(radius=1.0)
circle_2 = Circle(radius=1.0, color=GREEN)
circle_3 = Circle(radius=1.0, color=BLUE_B, fill_opacity=0.25)
circle_4 = Circle(radius=1.0, color=BLUE_B, fill_opacity=1)
circle_group = Group(circle_1, circle_2, circle_3,circle_4).arrange(buff=1)
self.add(circle_group)
运行结果:
2.三点定位圆[Circle.from_three_points]
cricle.from_three_points(p1, p2, p3)
#返回一个通过指定 三点。
实例:
from manim import *
class CircleFromPointsExample_three_points(Scene):
def construct(self):
dot=Dot(color=RED)
circle = Circle.from_three_points(2*LEFT, 2*DOWN, UP * 2,color=RED)
dots = VGroup(Dot(2*LEFT,color=YELLOW),Dot(2*DOWN),Dot(UP * 2))
self.add(NumberPlane(), dot,circle, dots)
运行结果:
3.圆上的角度【point_at_angle(angle)】
circle.point_at_angle(PI/2)
实例:
from manim import *
class PointAtAngleExample(Scene):
def construct(self):
circle = Circle(radius=2.0)
p1 = circle.point_at_angle(PI/4)
p2 = circle.point_at_angle(270*DEGREES)
p3 = circle.point_at_angle(180*DEGREES)
s1 = Square(side_length=0.25).move_to(p1)
s2 = Square(side_length=0.25).move_to(p2)
s3 = Circle(radius=0.25,color=YELLOW_A).move_to(p3)
self.add(NumberPlane(),circle, s1, s2,s3)
运行结果:
4.包含图像的圆surround()
surround(mobject, dim_to_match=0, stretch=False, buffer_factor=1.2)
是一个函数调用,通常用于图形和动画库(例如 Manim)中,目的是将一个对象(mobject
)包围在某个形状或边界之内。下面是参数的详细解释:
-
mobject: 这是要被包围的对象,通常是一个图形或形状。在 Manim 中,
mobject
可以是任意类型的可视对象。 -
dim_to_match=0: 这个参数指定了要与
mobject
匹配的维度。维度通常是 0(宽度)、1(高度)或 2(深度)。设置为 0 表示将匹配mobject
的宽度。 -
stretch=False: 这个布尔参数指示是否在包围
mobject
时进行拉伸。如果设置为True
,则可能会改变包围框的比例,以将其适应mobject
的尺寸。如果False
,则会保持原有的比例。 -
buffer_factor=1.2: 这个参数控制包围框相对于
mobject
的额外空白空间。具体来说,1.2 的buffer_factor
表示包围框将比mobject
的尺寸大 20%。如果你希望包围框更紧凑,可以减少这个值;如果希望有更多的空白,可以增加这个值。
这个函数一般用于创建视觉效果,让一个对象在画面中显得更加突出或者有框架的感觉。注意,实际使用时,可能需要根据具体的图形库的文档来参考详细的用法和效果。
实例:
from manim import *
class CircleSurround(Scene):
def construct(self):
triangle1 = Triangle()
circle1 = Circle().surround(triangle1)
group1 = Group(triangle1,circle1) #
line2 = Line(color=YELLOW_A)
circle2 = Circle().surround(line2, buffer_factor=0.5)
group2 = Group(line2,circle2)
square3 = Square()
circle3 = Circle().surround(square3, buffer_factor=1)
group3 = Group(square3, circle3)
square4 = Square()
circle4 = Circle().surround(square4, buffer_factor=1.5)
group4 = Group(square4, circle4)
group = Group(group1, group2,group3,group4).arrange(buff=1)
self.add(group)
运行结果: