【Manim动画教程】——基本几何 【弧-下】

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)包围在某个形状或边界之内。下面是参数的详细解释:

  1. mobject: 这是要被包围的对象,通常是一个图形或形状。在 Manim 中,mobject 可以是任意类型的可视对象。

  2. dim_to_match=0: 这个参数指定了要与 mobject 匹配的维度。维度通常是 0(宽度)、1(高度)或 2(深度)。设置为 0 表示将匹配 mobject 的宽度。

  3. stretch=False: 这个布尔参数指示是否在包围 mobject 时进行拉伸。如果设置为 True,则可能会改变包围框的比例,以将其适应 mobject 的尺寸。如果 False,则会保持原有的比例。

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

运行结果: 

 

  • 14
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yasen.M

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值