본문 바로가기

Programming/Manim Lectures

[06-1-B] Animation : Creation series

반응형

Animations that creates an object on the screen.


There are quite a few classes in this category, so we will divide them into 1)Showing 2)Fading 3)Growing.

 

The use of animation classes is simple because you can specify the class you want to use in the play method.

Therefore, learning about animation classes only needs to know what effect these classes have, so you can focus on the effects of those classes.

 

1) Showing

Show the object on the screen.

 

Class Parameters Explanation
ShowCreation mobject Displays objects as if they were drawn on the screen.
Write mobject Similar to ShowCreation, but with a pen-like effect when displaying text
DrawBorderThenFill mobject Write the outer outline of the object first and paint the inside
ShowIncreasingSubsets mobject Quickly display objects on the screen. Feels like drawing faster than ShowCreation
ShowSubmobjectsOneByOne mobject If an object consists of multiple objects, the sub-objects are displayed in turn.
Uncreate mobject In contrast to ShwoCreation, all objects are displayed on the screen at once, and the last object is deleted in order.
In other words, the effect of seeing and disappearing objects on the screen.
ShowCreationThenFadeOut mobject The object is displayed using ShowCreation, and then FadeOut immediately after it is drawn.

 

The code below is an example of trying out all of the animation classes that 'creation' effects.

 

    def showing(self):
        text = Text("Hello. This is animation test", size=0.5, stroke_width=0)
        circle1 = Circle(radius=1)
        circle2 = Circle(radius=1, fill_color=YELLOW, fill_opacity=1)
        line = Line(LEFT,RIGHT, stroke_width=10).set_width(4)

        circles = VGroup(circle1, circle2)

        text.next_to(circles,UP)
        circles.arrange(RIGHT)
        line.next_to(circles,DOWN)

        mobs = VGroup(text,circles,line)

        ani_classes = {
            "ShowCreation": ShowCreation,
            "Write": Write,
            "DrawBorderThenFill": DrawBorderThenFill,
            "ShowIncreasingSubsets": ShowIncreasingSubsets,
            "ShowSubmobjectsOneByOne": ShowSubmobjectsOneByOne,
            "Uncreate": Uncreate,
        }

        idx=1
        for name, ani in ani_classes.items():
            self.do_ani(idx, name, ani, mobs)
            idx += 1

    def do_ani(self, idx, ani_name, ani_class, mobs):
        text = Text(str(idx)+". "+ani_name, stroke_width=0, size=0.4, color=YELLOW)
        text.to_corner(UL)

        self.add(text)
        self.wait()
        self.play(ani_class(mobs), run_time=4)
        self.wait()
        self.remove(text,mobs)

 

youtu.be/__SmFD5jffs

1)Showing Animation

 


2) Fading

Animations that create a fade in/fade out effect that slowly appears or disappears on the screen.

 

Class Parameters Explanation
FadeIn mobject Make objects appear slowly on the screen
FadeInFrom mobject,
direction=None
Makes objects appear gradually as they come from the direction
FadeInFromDown mobject Make object appear slowly as it rises from the bottom
FadeInFromLarge mobject Makes objects appear gradually while being enlarged to their original size
FadeInFromPoint mobject, point Makes the object appear gradually from a given point
FadeOut mobject Make objects disappear slowly
FadeOutAndShift mobject,
direction=None
Move the object in the 'direction' to make it disappear gradually
FadeOutAndShiftDown mobject,
direction=None
Move the object downwards so that it disappears gradually
ShrinkToCenter mobject Makes the object disappear as if it is going to disappear toward the center of the object
VFadeIn mobject Make objects appear slowly. Applicable to VMobject only. Unlike FadeIn, VFadeIn is possible while the object performs different actions (shift, etc.)
VFadeOut
mobject Make objects disappear slowly. Applicable to VMobject only. Unlike FadeOut, VFadeOut is possible while the object performs different actions (shift, etc.)

 

Below is the code showing the behavior of the Showing related animation class.

 

    def fading(self):
        ani_classes = {
            "FadeIn": (FadeIn,),
            "FadeInFrom": (FadeInFrom, LEFT),
            "FadeInFromDown": (FadeInFromDown, ),
            "FadeInFromLarge": (FadeInFromLarge, ),
            "FadeInFromPoint": (FadeInFromPoint, DL),
            "FadeOut": (FadeOut, ),
            "FadeOutAndShift": (FadeOutAndShift, UP),
            "FadeOutAndShiftDown": (FadeOutAndShiftDown, ),
            "ShrinkToCenter": (ShrinkToCenter,),
            "VFadeIn": (VFadeIn,),
            "VFadeOut": (VFadeOut,),
        }

        idx = 1
        for name, ani in ani_classes.items():
            self.do_ani(idx,name, ani)
            idx += 1

    def do_ani(self, idx, ani_name, ani):
        def get_obj():
            text = Text("Hello. This is animation test", size=0.5, stroke_width=0)
            circle1 = Circle(radius=1)
            circle2 = Circle(radius=1, fill_color=YELLOW, fill_opacity=1)
            line = Line(LEFT, RIGHT, stroke_width=10).set_width(4)

            circles = VGroup(circle1, circle2)

            text.next_to(circles, UP)
            circles.arrange(RIGHT)
            line.next_to(circles, DOWN)

            return VGroup(text, circles, line)

        mobs = get_obj()
        name_text = Text(str(idx) + ". " + ani_name, stroke_width=0, size=0.4, color=YELLOW)
        name_text.to_corner(UL)

        self.add(name_text)
        self.wait()

        if len(ani) == 1:
            self.play(ani[0](mobs), run_time=4)
        else:
            self.play(ani[0](mobs, ani[1:]), run_time=4)

        self.wait()
        self.remove(name_text, mobs)    

 

2) Fading Animation

 


3) Growing

This is the animation that appears as the object starts at a small size and grows.

 

Class Parameters Explanation
GrowFromPoint mobject,
point
Start the object at a given point location and make it appear larger and larger
GrowFromCenter mobject Makes objects appear larger and larger from the center
GrowFromEdge mobject,
edge
Make it appear as it grows larger from the edge of the object. The edge of the object is 9 points: 4 corners, 4 centers of the edge, and the center of the object
SpinInFromNothing mobject Make objects appear as they rotate and grow larger
GrowArrow arrow Make the arrow object appear as it grows larger from the starting point of the arrow. Animable objects are objects that have a get_start() method. (Line series objects).

 

 

Below is the code and video to test the growing related classes.

    def do_ani(self, idx, ani_name, ani, obj=None):
        def get_obj():
            text = Text("Hello. This is animation test", size=0.5, stroke_width=0)
            circle1 = Circle(radius=1)
            circle2 = Circle(radius=1, fill_color=YELLOW, fill_opacity=1)
            line = Line(LEFT, RIGHT, stroke_width=10).set_width(4)

            circles = VGroup(circle1, circle2)

            text.next_to(circles, UP)
            circles = VGroup(circle1, circle2)
            circles.arrange(RIGHT)
            line.next_to(circles, DOWN)

            return VGroup(text, circles, line)

        if obj is None:
            mobs = get_obj()
        else:
            mobs = obj

        name_text = Text(str(idx) + ". " + ani_name, stroke_width=0, size=0.4, color=YELLOW)
        name_text.to_corner(UL)

        self.add(name_text)
        self.wait()

        if len(ani) == 1:
            self.play(ani[0](mobs), run_time=4)
        elif len(ani)==2:
            self.play(ani[0](mobs, ani[1]), run_time=4)
        elif len(ani) == 3:
            self.play(ani[0](mobs, ani[1], ani[2]), run_time=4)
        else:
            self.play(ani[0](mobs, ani[1:]), run_time=4)

        self.wait()
        self.remove(name_text, mobs)

    def growing(self):
        ani_classes = {
            "GrowFromPoint": (GrowFromPoint, DR),
            "GrowFromCenter": (GrowFromCenter, ),
            "GrowFromEdge": (GrowFromEdge, DL),
            "SpinInFromNothing": (SpinInFromNothing, ),
        }

        grow_arrow_class = {"GrowArrow": (GrowArrow,),}

        idx = 1
        for name, ani in ani_classes.items():
            self.do_ani(idx,name, ani)
            idx += 1

        arrow = Arrow(LEFT,RIGHT, color=YELLOW, buff=0)
        self.do_ani(idx,"GrowArrow",grow_arrow_class["GrowArrow"],obj=arrow)

 

3)Growing Animation

Next: [06-1-C] Animation : Indicating series

 

[06-1-C] Animation : Indicating series

The Indicating series animation class is an animation that draws attention to an object displayed on the screen while blinking it. Indicating related classes are as follows. Class Parameters Explan..

infograph.tistory.com

Go To: [99] Table of Contents

반응형

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

[06-1-D] Animation : Move/Rotating series  (0) 2020.06.09
[06-1-C] Animation : Indicating series  (0) 2020.06.09
[06-1-A] Animation Class and Rate Function  (2) 2020.06.09
[06-1] Animation by Classes  (0) 2020.06.09
[06] Animation  (0) 2020.06.09