본문 바로가기

Programming/Manim code

[003]mob.to_corner

반응형
class ToCornerTest(Scene):
    def construct(self):
        self.draw_border()
        self.to_corner_test()
        # self.to_corner_test(buff=0.5)

    def draw_border(self):
        border = Rectangle(width=FRAME_WIDTH, height=FRAME_HEIGHT, stroke_color=YELLOW)
        self.add(border)

    def to_corner_test(self, buff=0):
        text = Text("Hello", font='Arial', stroke_width=1, size=0.4)
        rect = Rectangle(width=0.3, height=text.get_height(), stroke_color=RED)

        group = VGroup(rect, text).arrange(RIGHT)
        group.save_state()
        self.add(group)

        for d in [UL, UR, DL, DR]:
            self.play(group.to_edge, d, {"buff": buff})
            self.wait()
            group.restore()
        self.remove(group)

 

 


 

class ToCornerTest(Scene):
    def construct(self):
        self.draw_border()
        # self.to_corner_test()
        self.to_corner_test(buff=0.5)

    def draw_border(self):
        border = Rectangle(width=FRAME_WIDTH, height=FRAME_HEIGHT, stroke_color=YELLOW)
        self.add(border)

    def to_corner_test(self, buff=0):
        text = Text("Hello", font='Arial', stroke_width=1, size=0.4)
        rect = Rectangle(width=0.3, height=text.get_height(), stroke_color=RED)

        group = VGroup(rect, text).arrange(RIGHT)
        group.save_state()
        self.add(group)

        for d in [UL, UR, DL, DR]:
            self.play(group.to_edge, d, {"buff": buff})
            self.wait()
            group.restore()
        self.remove(group)

 

 

반응형

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

[005]mob.shift  (0) 2020.05.05
[004]mob.next_to  (0) 2020.05.05
[002]mob.to_edge  (0) 2020.05.05
[001]mob.move_to  (0) 2020.05.05
about  (0) 2020.05.05