본문 바로가기

Programming/Manim code

[021]Polygon

반응형

Polygon

p=Polygon(UP+LEFT, ORIGIN, DOWN+LEFT, RIGHT)


RegularPolygon

p = RegularPolygon()


RegularPolygon: start_angle

        left = RegularPolygon()
        right = RegularPolygon(start_angle=PI/2)


RegularPolygon: n

    def regulat_test3(self):
        tracker = ValueTracker(3)

        rp = RegularPolygon(3, fill_opacity=1, fill_color=RED)
        num = DecimalNumber(3,num_decimal_places=0).next_to(rp,UP)

        def update_func(mob):
            n = int(tracker.get_value())
            new_mob = RegularPolygon(n, fill_opacity=1, fill_color=RED)
            mob.become(new_mob)
            num.set_value(n)

        self.add(rp, num)
        self.play(
            tracker.set_value, 12,
            UpdateFromFunc(rp,update_func),
            rate_func=linear, run_time=5
        )
        self.wait()

 

 

반응형

'Programming > Manim code' 카테고리의 다른 글

[023]Rectangle, Square, RoundedRectangle  (0) 2020.05.11
[022]Triangle/ArrowTip  (0) 2020.05.06
[020]Vector/TangentLine  (0) 2020.05.06
[019]Arrow/DoubleArrow  (0) 2020.05.06
[018]Line/DashedLine  (0) 2020.05.06