コード例 #1
0
    def get_logo_animations(self, logo):
        layers = logo.spike_layers
        for i, layer in enumerate(layers):
            random.shuffle(layer.submobjects)
            for spike in layer:
                spike.save_state()
                spike.scale(0.5)
                spike.apply_complex_function(np.log)
                spike.rotate(-90 * DEGREES, about_point=ORIGIN)
                spike.set_fill(opacity=0)
            layer.rotate(i * PI / 5)

        logo.iris_background.save_state()
        logo.iris_background.scale(0.25)
        logo.iris_background.fade(1)

        return [
            Restore(
                logo.iris_background,
                run_time=3,
            ),
            AnimationGroup(*[
                LaggedStartMap(
                    Restore,
                    layer,
                    run_time=3,
                    path_arc=180 * DEGREES,
                    # rate_func=squish_rate_func(smooth, a / 3.0, (a + 1.9) / 3.0),
                    lag_ratio=0.8,
                ) for layer, a in zip(layers, [0, 0.2, 0.1, 0])
            ]),
            Animation(logo.pupil),
        ]
コード例 #2
0
ファイル: paperclip.py プロジェクト: cr-xu/manim_sandbox
 def __init__(self, mobject, **kwargs):
     assert (isinstance(mobject, Mobject))
     digest_config(self, kwargs)
     if not hasattr(mobject, "lines"):
         self.generate_lines(mobject)
     if not hasattr(mobject, "rectangle"):
         self.generate_rec(mobject)
     mobject.rectangle.save_state()
     mobject.rectangle.set_width(0, stretch=True, about_edge=LEFT)
     AnimationGroup.__init__(self, ShowCreation(mobject.lines, lag_ratio=0),
                             Restore(mobject.rectangle), **kwargs)
コード例 #3
0
 def __init__(self, focal_point, **kwargs):
     digest_config(self, kwargs)
     circles = VGroup()
     for x in range(self.n_circles):
         circle = Circle(
             radius=self.big_radius,
             stroke_color=BLACK,
             stroke_width=0,
         )
         circle.add_updater(lambda c: c.move_to(focal_point))
         circle.save_state()
         circle.set_width(self.small_radius * 2)
         circle.set_stroke(self.color, self.start_stroke_width)
         circles.add(circle)
     animations = [Restore(circle) for circle in circles]
     super().__init__(*animations, **kwargs)
コード例 #4
0
    def get_logo_animations(self, logo):
        layers = logo.spike_layers

        for j, layer in enumerate(layers):
            for i, spike in enumerate(layer):
                spike.angle = (13 * (i + 1) * (j + 1) * TAU / 28) % TAU
                if spike.angle > PI:
                    spike.angle -= TAU
                spike.save_state()
                spike.rotate(spike.angle, about_point=ORIGIN)
                # spike.get_points()[1] = rotate_vector(
                #     spike.get_points()[1], TAU/28,
                # )
                # spike.get_points()[-1] = rotate_vector(
                #     spike.get_points()[-1], -TAU/28,
                # )

        def get_spike_animation(spike, **kwargs):
            return Restore(spike, path_arc=-spike.angle, **kwargs)

        logo.iris_background.save_state()
        # logo.iris_background.scale(0.49)
        logo.iris_background.set_fill(GREY_D, 0.5)

        return [
            Restore(
                logo.iris_background,
                rate_func=squish_rate_func(smooth, 2.0 / 3, 1),
                run_time=3,
            ),
            AnimationGroup(*[
                LaggedStartMap(
                    get_spike_animation,
                    layer,
                    run_time=2,
                    # rate_func=squish_rate_func(smooth, a / 3.0, (a + 0.9) / 3.0),
                    lag_ratio=0.2,
                ) for layer, a in zip(layers, [0, 2, 1, 0])
            ]),
            Animation(logo.pupil),
        ]
コード例 #5
0
ファイル: ford_circles.py プロジェクト: misaiya1/demo-solara
 def show_different_levels_of_zooming(self):
     self.zoom_in_on(1/2., 6)
     self.wait()
     self.acl = VGroup(self.axes, self.circles, self.labels)
     self.acl.save_state()
     # First Zoom
     self.play_farey_sum_animation(0, 1, 1, 1)
     self.wait()
     # Second Zoom
     self.play_zooming_animation(1/np.sqrt(2), 9, run_time = 2)
     self.play_farey_sum_animation(2, 3, 3, 4)
     self.wait()
     # Third Zoom
     self.play_zooming_animation(0.73, 5, run_time = 2)
     self.play_farey_sum_animation(5, 7, 8, 11)
     self.wait()
     # Fourth Zoom
     self.play_zooming_animation(0.74, 5, run_time = 2)
     self.play_farey_sum_animation(11, 15, 14, 19)
     self.play_farey_sum_animation(14, 19, 17, 23)
     self.wait()
     # Reset
     self.play(Restore(self.acl), lag_ratio = 0, run_time = 4)
     self.wait()
コード例 #6
0
    def construct(self):
        if 1 == 1:
            try:
                self.add_sound(
                    "sidewayoutput\\basicmanim\\transform001b_01_01_02_01_01.wav",
                    time_offset=18)
                self.add_sound(
                    "sidewayoutput\\basicmanim\\transform001b_01_01_02_02_01.wav",
                    time_offset=48)
                self.add_sound(
                    "sidewayoutput\\basicmanim\\transform001b_01_01_02_02_02.wav",
                    time_offset=93)
                self.add_sound(
                    "sidewayoutput\\basicmanim\\transform001b_01_01_02_03_01.wav",
                    time_offset=148)
            except:
                pass
            self.play(
                StartScreens01(
                    [],
                    [],
                    [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"],
                     [r"\textbf{\textit{Transform}}\\{Part\ \textspA{I}b}"],
                     [
                         r"\tiny{\textrm{basic-manim.210201951v0\_transform001b}}"
                     ], [],
                     [
                         r"\scriptsize{\textbf{Warning:\ The\ content\ may\ contain\ errors,\ mistakes\ and\ inaccuracies.\ Information\ must\ be\ verified\ and\ evaluated\ before\ use.}}"
                     ]],
                ))
        if 1 == 1:
            self.play(
                GrowFromCenter(
                    TextMobject(
                        r"\textit{\textbf{\underline{Apply\ Transform}}}").
                    shift([0, 3.6, 0])))
            rows, cols = (7, 3)
            x = 5.
            x0, y0 = axes_point([-2.5, x, cols - 1, -5],
                                [2., -1.1, rows - 1, 3])
            txtx = ["\\underline{state 1}", "\\underline{state 2}"]
            txty = ["Method", "ApplyMethod", "ApplyFunction"]

            a1 = [
                "\\normalsize{sq[0]}", "\\normalsize{sq[1]}",
                "\\normalsize{sq[2]}"
            ]
            a2 = [
                r"\normalsize{sq[0]\\.shift([" + str(x) + r",\,0,\,0])}",
                r"\normalsize{ApplyMethod(\\sq[1].shift,\,[" + str(x) +
                r",\,0,\,0])}",
                r"\normalsize{ApplyFunction(\\lambda\,mob:\,mob.shift([" +
                str(x) + r",\,0,\,0]),\,sq[2])}"
            ]
            sq = [GeomSquare(0.75) for i in range(3)]

            self.fadein(
                *[
                    TextMobject(txtx[i]).move_to(each)
                    for i, each in enumerate(coord_grid(x0[1:], y0[0:1]))
                ],
                *[
                    TextMobject(txty[i]).move_to(each)
                    for i, each in enumerate(coord_grid(x0[0:1], y0[1::2]))
                ],
                *[GeomPoint(each) for each in coord_grid(x0[1:3], y0[2::2])],
                *[
                    MobjectOrChars(np.ravel(list(zip(a1,
                                                     a2)))[i]).move_to(each)
                    for i, each in enumerate(coord_grid(x0[1:3], y0[1::2]))
                ],
                *[
                    sq[i].move_to(each)
                    for i, each in enumerate(coord_grid(x0[1:2], y0[2::2]))
                ],
                run_time=5)
            self.play(AnimationGroup(
                ShowCreation(sq[0].shift([x, 0, 0]), run_time=0),
                ApplyMethod(sq[1].shift, [x, 0, 0]),
                ApplyFunction(lambda mob: mob.shift([x, 0, 0]), sq[2])),
                      run_time=15)
            self.fadeout()
        if 1 == 1:
            self.play(
                GrowFromCenter(
                    TextMobject(
                        r"\textit{\textbf{\underline{Apply Method}}}").shift(
                            [0, 3.6, 0]).add_as_foreground(self)))
            rows, cols = (8, 2)
            x0, y0 = axes_point([-1.5, 6, cols], [3, -0.9, rows])
            txty = [
                MobjectOrChars(each) for each in [
                    r"FadeToColor(sq[0],\,RED)", r"ScaleInPlace(sq[1],\,0.5))",
                    "ShrinkToCenter(sq[2])", "Restore(sq[3])"
                ]
            ]
            a1 = [
                MobjectOrChars("\\normalsize{sq[" + str(i) + "]}")
                for i in range(4)
            ]
            sq = [GeomSquare(0.75) for i in range(4)]
            self.fadein(
                *[
                    to_get_zlist(a1, sq)[i].move_to(each)
                    for i, each in enumerate(coord_grid(x0[1:2], y0))
                ],
                *[GeomPoint(each) for each in coord_grid(x0[1:2], y0[1::2])],
            )
            self.wait()
            sq[3].save_state()
            self.play(AnimationGroup(
                IndicateThenFadeOut(TextMobject(
                    r"Transform(sq[3], Circle().scale(0.375).\\move\_to(sq[3]).shift([1, 0, 0])))"
                ).move_to([x0[0], y0[7], 0]),
                                    scale_factor=1,
                                    ratio_array=[1, 0]),
                Transform(
                    sq[3],
                    Circle().scale(0.375).move_to(sq[3]).shift([1, 0, 0]))),
                      run_time=5)
            self.wait()
            self.fadein(
                *[
                    txty[i].move_to(each)
                    for i, each in enumerate(coord_grid(x0[0:1], y0[1::2]))
                ], )
            self.play(AnimationGroup(
                FadeToColor(sq[0], RED),
                ScaleInPlace(sq[1], 0.5),
                ShrinkToCenter(sq[2]),
                Restore(sq[3]),
            ),
                      run_time=35)
            self.fadeout(exclude_mobjs="foreground")
        if 1 == 1:
            rows, cols = (6, 2)
            x0, y0 = axes_point([-1.5, 6, cols], [3, -0.9, rows])
            txty = [
                MobjectOrChars(each) for each in [
                    r"ApplyPointwiseFunction(\\lambda\,pointarray:\,pointarray\,+\,[1,\,0,\,0],\,sq[0])",
                    r"ApplyMatrix([[1.23,\,0.9],\,[0,\,1]],\,sq[1])",
                    r"ApplyComplexFunction(lambda pointarray:\\pointarray\,+\,np.complex(1,\,0),\,sq[2])",
                ]
            ]
            a1 = [
                MobjectOrChars("\\normalsize{sq[" + str(i) + "]}")
                for i in range(4)
            ]
            sq = [GeomSquare(0.75) for i in range(4)]
            self.fadein(
                *[
                    to_get_zlist(a1, sq)[i].move_to(each)
                    for i, each in enumerate(coord_grid(x0[1:2], y0))
                ],
                *[GeomPoint(each) for each in coord_grid(x0[1:2], y0[1::2])],
            )
            self.wait()
            self.fadein(
                *[
                    txty[i].move_to(each)
                    for i, each in enumerate(coord_grid(x0[0:1], y0[1::2]))
                ], )
            self.play(AnimationGroup(
                ApplyPointwiseFunction(
                    lambda pointarray: pointarray + [1, 0, 0], sq[0]),
                ApplyMatrix([[1.23, 0.9], [0, 1]], sq[1]),
                ApplyComplexFunction(
                    lambda pointarray: pointarray + np.complex(1, 0), sq[2]),
            ),
                      run_time=45)
            self.fadeout()
        if 1 == 1:
            self.play(
                GrowFromCenter(
                    TextMobject(
                        r"\textit{\textbf{\underline{Swap Method}}}").shift(
                            [0, 3.6, 0])))
            rows, cols = (2, 2)
            count = m, n = [2, 6]
            x0, y0 = axes_point([-3.5, 6, cols], [2.4, -3.7, rows])
            geometrys = [GeomLine(), GeomRegularPolygon(n, radius=2)]
            txty = [
                MobjectOrChars(each) for each in [
                    r"Swap(*sqs)\\ \tiny{(same as CyclicReplace)}",
                    r"CyclicReplace(*sqs)",
                ]
            ]
            titles = [
                [
                    MobjectOrChars("\\normalsize{sq[" + str(i) + "]}")
                    for i in range(m)
                ],
                [
                    MobjectOrChars("\\normalsize{sq[" + str(i) + "]}")
                    for i in range(n)
                ],
            ]
            sqs = [
                [GeomSquare(1.) for i in range(m)],
                [GeomSquare(1.) for i in range(n)],
            ]
            [[
                sq.add(title).add(GeomPoint())
                for sq, title in zip(sqs[i], titles[i])
            ] for i in range(len(count))]
            self.fadein(*[
                geometrys[i].move_to(each)
                for i, each in enumerate(coord_grid(x0[1:], y0[0:]))
            ])
            self.fadein(*[
                Group(*[
                    sqs[j][i].move_to(each) for i, each in enumerate(
                        geometrys[j].get_counting_points())
                ]) for j in range(2)
            ])
            self.fadein(
                *[
                    txty[i].move_to(each)
                    for i, each in enumerate(coord_grid(x0[0:1], y0[0:]))
                ], )
            self.play(AnimationGroup(
                Swap(*sqs[0]),
                CyclicReplace(*sqs[1]),
            ),
                      run_time=35)
            self.fadeout()
        if 1 == 1:
            self.play(EndScreen01())
        self.wait(5)
コード例 #7
0
 def get_spike_animation(spike, **kwargs):
     return Restore(spike, path_arc=-spike.angle, **kwargs)
コード例 #8
0
 def get_spike_animation(spike, **kwargs):
     return Restore(spike, **kwargs)
コード例 #9
0
    def construct(self):
        logo = self.logo
        name = self.channel_name

        layers = logo.spike_layers

        logo.save_state()

        for layer in layers:
            for spike in layer:
                spike.save_state()
                point = np.array(spike.get_points()[0])
                angle = angle_of_vector(point)
                spike.rotate(-angle + 90 * DEGREES)
                spike.stretch_to_fit_width(0.2)
                spike.stretch_to_fit_height(0.5)
                spike.point = point
            for spike in layer[::2]:
                spike.rotate(180 * DEGREES)
            layer.arrange(LEFT, buff=0.1)
        layers.arrange(UP)
        layers.to_edge(DOWN)

        wrong_spike = layers[1][-5]
        wrong_spike.real_saved_state = wrong_spike.saved_state.copy()
        wrong_spike.saved_state.scale(0.25, about_point=wrong_spike.point)
        wrong_spike.saved_state.rotate(90 * DEGREES)
        self.wrong_spike = wrong_spike

        def get_spike_animation(spike, **kwargs):
            return Restore(spike, **kwargs)

        logo.iris_background.save_state()
        logo.iris_background.set_fill(opacity=0.0)
        logo.iris_background.scale(0.8)

        alt_name = name.copy()
        alt_name.set_stroke(BLACK, 5)

        self.play(
            Restore(
                logo.iris_background,
                rate_func=squish_rate_func(smooth, 1.0 / 3, 1),
                run_time=2,
            ),
            AnimationGroup(*(
                LaggedStartMap(
                    get_spike_animation,
                    layer,
                    run_time=2,
                    # rate_func=squish_rate_func(smooth, a / 3.0, (a + 0.9) / 3.0),
                    lag_ratio=2 / len(layer),
                    path_arc=-90 * DEGREES)
                for layer, a in zip(layers, [0, 2, 1, 0]))),
            Animation(logo.pupil),
            Write(alt_name),
            Write(name),
            run_time=3)

        self.wait(0.25)
        self.play(Transform(
            wrong_spike,
            wrong_spike.real_saved_state,
        ),
                  Animation(self.logo),
                  run_time=0.75)
コード例 #10
0
    def __init__(self,
                 parbs,
                 anibs,
                 sndbs,
                 j_start=1,
                 j_first=None,
                 j_count=None,
                 i_start=1,
                 i_first=None,
                 i_count=None,
                 j_position=GeomPosition([-6.5, 3.3, 0]),
                 j_width=[13],
                 j_height=7,
                 i_position=GeomPosition([0, 3.3, 0]),
                 i_width=[6.75],
                 i_height=7,
                 mobjs=None,
                 scene=None,
                 **kwargs):
        if j_count is None:
            j_count = len(parbs[0])
        if j_first is None:
            j_first = j_start
        if scene is None:
            scene = V.scene
        if mobjs is None:
            mobjs = AnimatedGroup().scale(0.2).post_to(scene)
        animations = AGroup()
        if 1 == 1:
            animations.add(
                AnimationGroup(Animation(Mobject()),
                               sound=sndbs[0][0],
                               xaction="sound"))
            animations.add(
                AnimationGroup(GrowTitle(parbs[0][0]),
                               Freeze(4),
                               anibs[0][0],
                               foreground=True,
                               xaction="post"))
        j_end = min((j_start + j_count), len(parbs[0]), len(anibs[0]))
        grpa = VGroup(j_position)
        OrderedGroup(grpa, ["/"] * (j_start - 1) + parbs[0][j_start:],
                     width=j_width).post_to(scene)  #["/"]*(i_start-1)+
        blka = VGroup().save_state()
        blk = [grpa[j_first:j_first + i + 1] for i in range(j_count + 1)]
        blk[0].save_state()
        for j in range(j_start, j_end):
            print("j", j)
            grpa[j].add_to_group(blka)
            rcca = VGroup()
            while blka.get_height() > j_height:
                if len(blka) == 1:
                    grpa[j].stretch_to_fit_height(j_height - 0.05)
                else:
                    blka[0].add_to_group(rcca).remove_from_group(blka)
            if j >= j_first:
                animations.add(
                    AnimationGroup(Animation(Mobject()),
                                   sound=sndbs[0][j],
                                   xaction="sound"))
                animations.add(
                    AnimationGroup(
                        PlayMobject(mobjs.copy().next_to(grpa[j]), grpa[j]),
                        DiminishToSide(rcca), Write(grpa[j]), anibs[0][j],
                        Freeze(2)))
            else:
                animations.add(
                    AnimationGroup(DiminishToSide(rcca),
                                   Animation(grpa[j]),
                                   anibs[0][j],
                                   xaction="display"))
            if 1 == 1 and j >= j_first:
                animations.add(
                    AnimationGroup(DiminishToEdge(blk[j -
                                                      j_first].save_state()),
                                   run_time=0.5))
                animations.add(
                    *SlideShow01(parbs[j], anibs[j], sndbs[j], i_start,
                                 i_count, i_first).animations)
                animations.add(
                    AnimationGroup(exclude_mobjs="foreground",
                                   xaction="fadeout"))
                if j < j_end - 1:
                    animations.add(
                        AnimationGroup(Restore(blk[j - j_first]),
                                       run_time=0.5))

        super().__init__(*animations, )