Exemplo n.º 1
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     circle = Circle(
         stroke_width=3,
         stroke_color=GREEN,
         fill_opacity=1,
         fill_color=BLUE_C,
     )
     circle.replace(self)
     self.add_to_back(circle)
Exemplo n.º 2
0
    def animate_product(self, left, right, result):
        l_matrix = left.get_mob_matrix()
        r_matrix = right.get_mob_matrix()
        result_matrix = result.get_mob_matrix()
        circle = Circle(
            radius=l_matrix[0][0].get_height(),
            color=GREEN
        )
        circles = VGroup(*[
            entry.get_point_mobject()
            for entry in (l_matrix[0][0], r_matrix[0][0])
        ])
        (m, k), n = l_matrix.shape, r_matrix.shape[1]
        for mob in result_matrix.flatten():
            mob.set_color(BLACK)
        lagging_anims = []
        for a in range(m):
            for b in range(n):
                for c in range(k):
                    l_matrix[a][c].set_color(YELLOW)
                    r_matrix[c][b].set_color(YELLOW)
                for c in range(k):
                    start_parts = VGroup(
                        l_matrix[a][c].copy(),
                        r_matrix[c][b].copy()
                    )
                    result_entry = result_matrix[a][b].split()[c]

                    new_circles = VGroup(*[
                        circle.copy().shift(part.get_center())
                        for part in start_parts.split()
                    ])
                    self.play(Transform(circles, new_circles))
                    self.play(
                        Transform(
                            start_parts,
                            result_entry.copy().set_color(YELLOW),
                            path_arc=-np.pi / 2,
                            lag_ratio=0,
                        ),
                        *lagging_anims
                    )
                    result_entry.set_color(YELLOW)
                    self.remove(start_parts)
                    lagging_anims = [
                        ApplyMethod(result_entry.set_color, WHITE)
                    ]

                for c in range(k):
                    l_matrix[a][c].set_color(WHITE)
                    r_matrix[c][b].set_color(WHITE)
        self.play(FadeOut(circles), *lagging_anims)
        self.wait()
Exemplo n.º 3
0
    def init_pupils(self):
        # Instead of what is drawn, make new circles.
        # This is mostly because the paths associated
        # with the eyes in all the drawings got slightly
        # messed up.
        for eye, pupil in zip(self.eyes, self.pupils):
            pupil_r = eye.get_width() / 2
            pupil_r *= self.pupil_to_eye_width_ratio
            dot_r = pupil_r
            dot_r *= self.pupil_dot_to_pupil_width_ratio

            new_pupil = Circle(
                radius=pupil_r,
                color=BLACK,
                fill_opacity=1,
                stroke_width=0,
            )
            dot = Circle(
                radius=dot_r,
                color=WHITE,
                fill_opacity=1,
                stroke_width=0,
            )
            new_pupil.move_to(pupil)
            pupil.become(new_pupil)
            dot.shift(
                new_pupil.get_boundary_point(UL) -
                dot.get_boundary_point(UL)
            )
            pupil.add(dot)
Exemplo n.º 4
0
    def increment(self, run_time_per_anim=1):
        moving_dot = Dot(
            self.counting_dot_starting_position,
            radius=self.count_dot_starting_radius,
            color=self.digit_place_colors[0],
        )
        moving_dot.generate_target()
        moving_dot.set_fill(opacity=0)
        kwargs = {
            "run_time": run_time_per_anim
        }

        continue_rolling_over = True
        first_move = True
        place = 0
        while continue_rolling_over:
            added_anims = []
            if first_move:
                added_anims += self.get_digit_increment_animations()
                first_move = False
            moving_dot.target.replace(
                next(self.dot_template_iterators[place])
            )
            self.play(MoveToTarget(moving_dot), *added_anims, **kwargs)
            self.curr_configurations[place].add(moving_dot)

            if len(self.curr_configurations[place].split()) == self.get_place_max(place):
                full_configuration = self.curr_configurations[place]
                self.curr_configurations[place] = VGroup()
                place += 1
                center = full_configuration.get_center_of_mass()
                radius = 0.6 * max(
                    full_configuration.get_width(),
                    full_configuration.get_height(),
                )
                circle = Circle(
                    radius=radius,
                    stroke_width=0,
                    fill_color=self.digit_place_colors[place],
                    fill_opacity=0.5,
                )
                circle.move_to(center)
                moving_dot = VGroup(circle, full_configuration)
                moving_dot.generate_target()
                moving_dot[0].set_fill(opacity=0)
            else:
                continue_rolling_over = False
Exemplo n.º 5
0
 def add_pupil(self):
     self.pupil = Circle(
         radius=self.pupil_radius,
         fill_color=BLACK,
         fill_opacity=1,
         stroke_width=0,
         sheen=0.0,
     )
     self.pupil.rotate(90 * DEGREES)
     self.add(self.pupil)
Exemplo n.º 6
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)
Exemplo n.º 7
0
class Logo(VMobject):
    CONFIG = {
        "pupil_radius": 1.0,
        "outer_radius": 2.0,
        "iris_background_blue": "#74C0E3",
        "iris_background_brown": "#8C6239",
        "blue_spike_colors": [
            "#528EA3",
            "#3E6576",
            "#224C5B",
            BLACK,
        ],
        "brown_spike_colors": [
            "#754C24",
            "#603813",
            "#42210b",
            BLACK,
        ],
        "n_spike_layers": 4,
        "n_spikes": 28,
        "spike_angle": TAU / 28,
    }

    def __init__(self, **kwargs):
        VMobject.__init__(self, **kwargs)
        self.add_iris_back()
        self.add_spikes()
        self.add_pupil()

    def add_iris_back(self):
        blue_iris_back = AnnularSector(
            inner_radius=self.pupil_radius,
            outer_radius=self.outer_radius,
            angle=270 * DEGREES,
            start_angle=180 * DEGREES,
            fill_color=self.iris_background_blue,
            fill_opacity=1,
            stroke_width=0,
        )
        brown_iris_back = AnnularSector(
            inner_radius=self.pupil_radius,
            outer_radius=self.outer_radius,
            angle=90 * DEGREES,
            start_angle=90 * DEGREES,
            fill_color=self.iris_background_brown,
            fill_opacity=1,
            stroke_width=0,
        )
        self.iris_background = VGroup(
            blue_iris_back,
            brown_iris_back,
        )
        self.add(self.iris_background)

    def add_spikes(self):
        layers = VGroup()
        radii = np.linspace(
            self.outer_radius,
            self.pupil_radius,
            self.n_spike_layers,
            endpoint=False,
        )
        radii[:2] = radii[1::-1]  # Swap first two
        radii[-1] = interpolate(radii[-1], self.pupil_radius, 0.25)

        for radius in radii:
            tip_angle = self.spike_angle
            half_base = radius * np.tan(tip_angle)
            triangle, right_half_triangle = [
                Polygon(
                    radius * UP,
                    half_base * RIGHT,
                    vertex3,
                    fill_opacity=1,
                    stroke_width=0,
                ) for vertex3 in (
                    half_base * LEFT,
                    ORIGIN,
                )
            ]
            left_half_triangle = right_half_triangle.copy()
            left_half_triangle.flip(UP, about_point=ORIGIN)

            n_spikes = self.n_spikes
            full_spikes = [
                triangle.copy().rotate(-angle, about_point=ORIGIN)
                for angle in np.linspace(0, TAU, n_spikes, endpoint=False)
            ]
            index = (3 * n_spikes) // 4
            if radius == radii[0]:
                layer = VGroup(*full_spikes)
                layer.rotate(-TAU / n_spikes / 2, about_point=ORIGIN)
                layer.brown_index = index
            else:
                half_spikes = [
                    right_half_triangle.copy(),
                    left_half_triangle.copy().rotate(
                        90 * DEGREES,
                        about_point=ORIGIN,
                    ),
                    right_half_triangle.copy().rotate(
                        90 * DEGREES,
                        about_point=ORIGIN,
                    ),
                    left_half_triangle.copy()
                ]
                layer = VGroup(*it.chain(
                    half_spikes[:1],
                    full_spikes[1:index],
                    half_spikes[1:3],
                    full_spikes[index + 1:],
                    half_spikes[3:],
                ))
                layer.brown_index = index + 1

            layers.add(layer)

        # Color spikes
        blues = self.blue_spike_colors
        browns = self.brown_spike_colors
        for layer, blue, brown in zip(layers, blues, browns):
            index = layer.brown_index
            layer[:index].set_color(blue)
            layer[index:].set_color(brown)

        self.spike_layers = layers
        self.add(layers)

    def add_pupil(self):
        self.pupil = Circle(
            radius=self.pupil_radius,
            fill_color=BLACK,
            fill_opacity=1,
            stroke_width=0,
            sheen=0.0,
        )
        self.pupil.rotate(90 * DEGREES)
        self.add(self.pupil)

    def cut_pupil(self):
        pupil = self.pupil
        center = pupil.get_center()
        new_pupil = VGroup(*[
            pupil.copy().pointwise_become_partial(pupil, a, b)
            for (a, b) in [(0.25, 1), (0, 0.25)]
        ])
        for sector in new_pupil:
            sector.add_cubic_bezier_curve_to(
                [sector.points[-1], *[center] * 3, *[sector.points[0]] * 2])
        self.remove(pupil)
        self.add(new_pupil)
        self.pupil = new_pupil

    def get_blue_part_and_brown_part(self):
        if len(self.pupil) == 1:
            self.cut_pupil()
        # circle = Circle()
        # circle.set_stroke(width=0)
        # circle.set_fill(BLACK, opacity=1)
        # circle.match_width(self)
        # circle.move_to(self)
        blue_part = VGroup(
            self.iris_background[0],
            *[layer[:layer.brown_index] for layer in self.spike_layers],
            self.pupil[0],
        )
        brown_part = VGroup(
            self.iris_background[1],
            *[layer[layer.brown_index:] for layer in self.spike_layers],
            self.pupil[1],
        )
        return blue_part, brown_part
Exemplo n.º 8
0
class Logo(VMobject):
    CONFIG = {
        "pupil_radius": 1.0,
        "outer_radius": 2.0,
        "iris_background_blue": "#74C0E3",
        "iris_background_brown": "#8C6239",
        "blue_spike_colors": [
            "#528EA3",
            "#3E6576",
            "#224C5B",
            BLACK,
        ],
        "brown_spike_colors": [
            "#754C24",
            "#603813",
            "#42210b",
            BLACK,
        ],
        "n_spike_layers": 4,
        "n_spikes": 28,
        "spike_angle": TAU / 28,
    }

    def __init__(self, **kwargs):
        VMobject.__init__(self, **kwargs)
        self.add_iris_back()
        self.add_spikes()
        self.add_pupil()

    def add_iris_back(self):
        blue_iris_back = AnnularSector(
            inner_radius=self.pupil_radius,
            outer_radius=self.outer_radius,
            angle=270 * DEGREES,
            start_angle=180 * DEGREES,
            fill_color=self.iris_background_blue,
            fill_opacity=1,
            stroke_width=0,
        )
        brown_iris_back = AnnularSector(
            inner_radius=self.pupil_radius,
            outer_radius=self.outer_radius,
            angle=90 * DEGREES,
            start_angle=90 * DEGREES,
            fill_color=self.iris_background_brown,
            fill_opacity=1,
            stroke_width=0,
        )
        self.iris_background = VGroup(
            blue_iris_back,
            brown_iris_back,
        )
        self.add(self.iris_background)

    def add_spikes(self):
        layers = VGroup()
        radii = np.linspace(
            self.outer_radius,
            self.pupil_radius,
            self.n_spike_layers,
            endpoint=False,
        )
        radii[:2] = radii[1::-1]  # Swap first two
        radii[-1] = interpolate(
            radii[-1], self.pupil_radius, 0.25
        )

        for radius in radii:
            tip_angle = self.spike_angle
            half_base = radius * np.tan(tip_angle)
            triangle, right_half_triangle = [
                Polygon(
                    radius * UP,
                    half_base * RIGHT,
                    vertex3,
                    fill_opacity=1,
                    stroke_width=0,
                )
                for vertex3 in (half_base * LEFT, ORIGIN,)
            ]
            left_half_triangle = right_half_triangle.copy()
            left_half_triangle.flip(UP, about_point=ORIGIN)

            n_spikes = self.n_spikes
            full_spikes = [
                triangle.copy().rotate(
                    -angle,
                    about_point=ORIGIN
                )
                for angle in np.linspace(
                    0, TAU, n_spikes, endpoint=False
                )
            ]
            index = (3 * n_spikes) // 4
            if radius == radii[0]:
                layer = VGroup(*full_spikes)
                layer.rotate(
                    -TAU / n_spikes / 2,
                    about_point=ORIGIN
                )
                layer.brown_index = index
            else:
                half_spikes = [
                    right_half_triangle.copy(),
                    left_half_triangle.copy().rotate(
                        90 * DEGREES, about_point=ORIGIN,
                    ),
                    right_half_triangle.copy().rotate(
                        90 * DEGREES, about_point=ORIGIN,
                    ),
                    left_half_triangle.copy()
                ]
                layer = VGroup(*it.chain(
                    half_spikes[:1],
                    full_spikes[1:index],
                    half_spikes[1:3],
                    full_spikes[index + 1:],
                    half_spikes[3:],
                ))
                layer.brown_index = index + 1

            layers.add(layer)

        # Color spikes
        blues = self.blue_spike_colors
        browns = self.brown_spike_colors
        for layer, blue, brown in zip(layers, blues, browns):
            index = layer.brown_index
            layer[:index].set_color(blue)
            layer[index:].set_color(brown)

        self.spike_layers = layers
        self.add(layers)

    def add_pupil(self):
        self.pupil = Circle(
            radius=self.pupil_radius,
            fill_color=BLACK,
            fill_opacity=1,
            stroke_width=0,
            sheen=0.0,
        )
        self.pupil.rotate(90 * DEGREES)
        self.add(self.pupil)

    def cut_pupil(self):
        pupil = self.pupil
        center = pupil.get_center()
        new_pupil = VGroup(*[
            pupil.copy().pointwise_become_partial(pupil, a, b)
            for (a, b) in [(0.25, 1), (0, 0.25)]
        ])
        for sector in new_pupil:
            sector.add_cubic_bezier_curve_to([
                sector.points[-1],
                *[center] * 3,
                *[sector.points[0]] * 2
            ])
        self.remove(pupil)
        self.add(new_pupil)
        self.pupil = new_pupil

    def get_blue_part_and_brown_part(self):
        if len(self.pupil) == 1:
            self.cut_pupil()
        # circle = Circle()
        # circle.set_stroke(width=0)
        # circle.set_fill(BLACK, opacity=1)
        # circle.match_width(self)
        # circle.move_to(self)
        blue_part = VGroup(
            self.iris_background[0],
            *[
                layer[:layer.brown_index]
                for layer in self.spike_layers
            ],
            self.pupil[0],
        )
        brown_part = VGroup(
            self.iris_background[1],
            *[
                layer[layer.brown_index:]
                for layer in self.spike_layers
            ],
            self.pupil[1],
        )
        return blue_part, brown_part
Exemplo n.º 9
0
 def get_seed_shape(self):
     return Circle()
Exemplo n.º 10
0
 def get_circle(self, mobject):
     circle = Circle(**self.circle_config)
     circle.add_updater(lambda c: c.surround(mobject))
     return circle
Exemplo n.º 11
0
 def ellipse_to_mobject(self, ellipse: se.Ellipse) -> Circle:
     mob = Circle(radius=ellipse.rx)
     mob.stretch_to_fit_height(2 * ellipse.ry)
     mob.shift(_convert_point_to_3d(ellipse.cx, ellipse.cy))
     return mob
Exemplo n.º 12
0
 def __init__(self, mobject, **kwargs):
     digest_config(self, kwargs)
     circle = Circle(color=self.color, **kwargs)
     circle.surround(mobject)
     Indicate.__init__(self, circle, **kwargs)
Exemplo n.º 13
0
 def construct(self):
     if 1 == 1:
         try:
             self.add_sound(
                 "sidewayoutput\\basicmanim\\transform001a_01_01_01_01_01.wav",
                 time_offset=18)
             self.add_sound(
                 "sidewayoutput\\basicmanim\\transform001a_01_01_01_02_01.wav",
                 time_offset=93)
             self.add_sound(
                 "sidewayoutput\\basicmanim\\transform001a_01_01_01_03_01.wav",
                 time_offset=135)
         except:
             pass
         self.play(
             StartScreens01(
                 [],
                 [],
                 [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"],
                  [r"\textbf{\textit{Transform}}\\{{Part\ \textspA{I}a}"],
                  [
                      r"\tiny{\textrm{basic-manim.210200551v0\_transform001a}}"
                  ], [],
                  [
                      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{Transform}}}").shift(
                         [0, 3.6, 0])))
         squarea = Square()
         squareb = Square(side_length=4).shift([4, 0, 0])
         circlea = Circle()
         circleb = Circle(radius=2).shift([-4, 0, 0])
         linea = Line([-4, 3, 0], [4, 3, 0])
         lineb = Line([-3, -3, 0], [3, -3, 0])
         texta = TextMobject("AB").shift([0, -2.5, 0])
         textb = TextMobject("HI").shift([0, 2.5, 0])
         self.play(
             ShowCreation(Group(squarea, circlea, squareb, circleb, linea,
                                lineb),
                          lag_ratio=1,
                          run_time=12))
         self.play(Write(VGroup(texta, textb), lag_ratio=1, run_time=10))
         self.play(Transform(circlea, squarea, run_time=5))
         self.play(Transform(circlea, squareb, path_arc=3, run_time=5))
         self.play(Transform(squarea, circleb, path_arc=3, run_time=5))
         self.play(Transform(linea, lineb, path_arc=3, run_time=5))
         self.play(Transform(linea, circleb, path_arc=3, run_time=5))
         self.play(Transform(squareb, lineb, path_arc=3, run_time=5))
         self.play(Transform(texta, textb, path_arc=3, run_time=5))
         self.play(Transform(texta, circleb, path_arc=3, run_time=5))
         self.play(Transform(squareb, textb, path_arc=3, run_time=5))
         self.fadeout()
     if 1 == 1:
         self.play(
             GrowFromCenter(
                 TextMobject(
                     r"\textit{\textbf{\underline{Paths\ of\ Transform}}}").
                 shift([0, 3.6, 0])))
         rows, cols = (7, 5)
         x0, y0 = axes_point([0, 2, cols - 1, -4], [2.3, -1, rows - 1, 3])
         txtx = ["loc 1", "loc 2", "m1", "m2"]
         txty = [
             "ClockwiseTransform", "Transform", "CounterclockwiseTransform"
         ]
         a1 = Group()
         a2 = Group()
         a3 = Group()
         a4 = Group()
         for j in range(1, rows):
             a1.add(Circle().scale(0.2).move_to([x0[1], y0[j], 0]))
             a2.add(Square().scale(0.2).move_to([x0[2], y0[j], 0]))
             a3.add(
                 Dot([x0[3], y0[j], 0]).add_updater(lambda mob, obj=a1[
                     j - 1], x=x0[3], y=y0[j]: mob.become(obj.copy(
                     ).move_to([x, y, 0]))).suspend_updating())
             a4.add(
                 Dot([x0[4], y0[j], 0]).add_updater(lambda mob, obj=a2[
                     j - 1], x=x0[4], y=y0[j]: mob.become(obj.copy(
                     ).move_to([x, y, 0]))).suspend_updating())
         self.play(FadeIn(
             Group(
                 *[
                     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]))
                 ], *[Dot(each) for each in coord_grid(x0[1:3], y0[1:])],
                 TextMobject(r"$\rightarrow$").move_to(
                     ([(x0[1] + x0[2]) / 2, y0[0], 0])), a1[::2], a2[::2],
                 a3, a4, *[
                     Square(stroke_width=2,
                            color="#FFFF00",
                            fill_opacity=0.3).add_updater(
                                lambda mob, obj=obj: mob.surround(
                                    obj, stretch=True, buff=0.2))
                     for obj in a1
                 ], *[
                     Square(stroke_width=2, color="#DC75CD").add_updater(
                         lambda mob, obj=obj: mob.surround(
                             obj, stretch=True, buff=0.3)) for obj in a2
                 ])),
                   run_time=5)
         self.wait(2)
         self.play(AnimationGroup(
             ClockwiseTransform(a2[0], a1[0]),
             ClockwiseTransform(a1[1], a2[1]),
             Transform(a1[2], a2[2]),
             Transform(a2[3], a1[3]),
             CounterclockwiseTransform(a1[4], a2[4]),
             CounterclockwiseTransform(a2[5], a1[5]),
         ),
                   run_time=25)
         self.wait(3)
         a1.shift([0.3, 0, 0]).set_color("#11FF00")
         self.wait(3)
         self.play(ApplyMethod(a1.shift, ([0.3, 0, 0])), run_time=3)
         self.fadeout()
     if 1 == 1:
         self.play(
             GrowFromCenter(
                 TextMobject(
                     r"\textit{\textbf{\underline{Methods\ of\ Transform}}}"
                 ).shift([0, 3.6, 0])))
         rows, cols = (9, 5)
         x0, y0 = axes_point([0, 2, cols - 1, -4], [2.3, -0.8, rows - 1, 3])
         txtx = ["loc 1", "loc 2", "m1", "m2"]
         txty = [
             "Transform", "ReplacementTransform", "TransformFromCopy",
             "MoveToTarget"
         ]
         a1 = Group()
         a2 = Group()
         a3 = Group()
         a4 = Group()
         for j in range(1, rows):
             a1.add(Circle().scale(0.2).move_to([x0[1], y0[j], 0]))
             a2.add(Square().scale(0.2).move_to([x0[2], y0[j], 0]))
             a3.add(Dot().move_to([x0[3], y0[j], 0]).add_updater(
                 lambda mob, obj=a1[j - 1], x=x0[3], y=y0[j]: mob.become(
                     obj.copy().move_to([x, y, 0]))).suspend_updating())
             a4.add(Dot().move_to([x0[4], y0[j], 0]).add_updater(
                 lambda mob, obj=a2[j - 1], x=x0[4], y=y0[j]: mob.become(
                     obj.copy().move_to([x, y, 0]))).suspend_updating())
         a1[6].target = a2[6]
         a1[7].target = a2[7]
         self.play(FadeIn(
             Group(
                 *[
                     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]))
                 ], *[Dot(each) for each in coord_grid(x0[1:3], y0[1:])],
                 TextMobject(r"$\rightarrow$").move_to(
                     ([(x0[1] + x0[2]) / 2, y0[0], 0])), a1[::2], a2[::2],
                 a3, a4,
                 Group(*[
                     Square(
                         stroke_width=2, color="#FFFF00", fill_opacity=0.3).
                     add_updater(lambda mob, obj=obj: mob.surround(
                         obj, stretch=True, buff=0.2)) for obj in a1
                 ]),
                 Group(*[
                     Square(stroke_width=2, color="#DC75CD").add_updater(
                         lambda mob, obj=obj: mob.surround(
                             obj, stretch=True, buff=0.3)) for obj in a2
                 ]))),
                   run_time=5)
         self.wait(2)
         self.play(AnimationGroup(Transform(a1[0], a2[0]),
                                  Transform(a1[1], a2[1]),
                                  ReplacementTransform(a1[2], a2[2]),
                                  ReplacementTransform(a1[3], a2[3]),
                                  TransformFromCopy(a1[4], a2[4]),
                                  TransformFromCopy(a1[5], a2[5]),
                                  MoveToTarget(a1[6]), MoveToTarget(a1[7])),
                   run_time=40)
         self.wait(3)
         a1.shift([0.3, 0, 0]).set_color("#11FF00")
         self.wait(10)
         self.play(ApplyMethod(a1.shift, ([0.3, 0, 0])), run_time=5)
         self.fadeout()
     if 1 == 1:
         self.play(EndScreen01())
     self.wait(5)
Exemplo n.º 14
0
 def __init__(self, **kwargs):
     Circle.__init__(self, **kwargs)
     plus = TexMobject("+")
     plus.scale(0.7)
     plus.move_to(self)
     self.add(plus)
Exemplo n.º 15
0
    def __init__(self,
                 screen01=[],
                 screen02=[],
                 screen03=[],
                 lag_ratio=1,
                 **kwargs):
        mobjs_1, mobjs_1_scale, mobjs_1_interval, mobjs_1_rate_func, \
            title_1, title_1_color, title_1_scale, title_1_position, title_1_shadow, \
            title_1_indicate_scale_factor, title_1_extra = screen01 + \
            ["", 2, 0.5, linear, "", "#0808B8", 2, [DOWN], [2, slice(0, 3, 2)],
             1.2, ""][len(screen01):]
        mobjs_2, mobjs_2_scale, mobjs_2_interval, mobjs_2_rate_func, \
            title_2, title_2_color, title_2_scale, title_2_position, title_2_shadow, \
            title_2_indicate_scale_factor, title_2_extra = screen02 + \
            ["", 2, 0.5, linear, "", "#0808B8", 1.2, [DOWN], [2, slice(1, 4, 2)],
             "", [slice(1, 2), WHITE, [-2.5, 0, 0]]][len(screen02):]
        [title, subtitle, filename, reference, warning, mobjes_3_run_time] =\
            screen03 + [[], [], [], [], [], 3][len(screen03):]
        [title, title_color, title_scale, title_position] = title + \
            ["", WHITE, 1, [UP]][len(title):]
        [subtitle, subtitle_color, subtitle_scale, subtitle_position] = subtitle + \
            ["", WHITE, 1, [0, 0, 0]][len(subtitle):]
        [filename, filename_color, filename_scale, filename_position] = filename + \
            ["", WHITE, 1, [0, -2.9, 0]][len(filename):]
        [reference, reference_color, reference_scale, reference_position] = reference + \
            ["", YELLOW, 1, [0, -3.3, 0]][len(reference):]
        [warning, warning_color, warning_scale, warning_position] = warning + \
            ["", YELLOW, 1, [0, -3.7, 0]
             ][len(warning):]

        startscreens = AGroup()
        if mobjs_1 != None:
            if mobjs_1 == "":
                try:
                    mobjs_1 = ImageMobjectGroup(
                        np.char.mod('%01d', range(0, 10)),
                        "sidewayoutput\\sidewayoutput2020yt")
                except:
                    mobjs_1 = ImageMobjectGroup(
                        np.char.mod('%01d', range(9, -1, -1)), "001\\")
            if title_1 == "":
                title_1 = PoweredBy
            title_1 = MobjectOrChars(title_1)
            title_1.set_color(title_1_color).scale(
                title_1_scale).align_on_border(
                    *title_1_position).add_shadow_mobjects(
                        title_1_shadow[0], title_1[title_1_shadow[1]])
            if title_1_extra != "":
                title_1[title_1_extra[0]].set_color(title_1_extra[1]).shift(
                    title_1_extra[2])
            if title_1_indicate_scale_factor == "":
                title_width = mobjs_1.get_width()
                title_1_indicate_scale_factor = (title_width -
                                                 0.5) / title_width
            startscreens.add(
                ShowSubmobjectsOneByOneAndFadeInThenIndicateThenFadeOut(
                    mobjs_1.scale(mobjs_1_scale),
                    title_1,
                    indicate_scale_factor=title_1_indicate_scale_factor,
                    show_rate_func=mobjs_1_rate_func,
                    run_time=mobjs_1_interval * (len(mobjs_1)),
                    **kwargs))
        if mobjs_2 != None:
            if mobjs_2 == "":
                strs = TextMobject(r"\textspA{%s}" % Project)
                mobjs_2 = Group(
                    Circle(fill_opacity=0.75),
                    RegularPolygon(fill_opacity=0.75),
                    Triangle(color=GREEN, fill_opacity=0.75),
                    Square(fill_opacity=0.75),
                    strs.set_color("#FFFFFF"),
                    strs.copy().set_color("#F8F8F8").scale(1.3),
                    strs.copy().set_color("#F8F8B8").scale(1.6),
                    strs.copy().set_color("#B8B8B8").scale(1.6),
                    strs.copy().set_color("#8888B8").scale(1.6),
                    strs.copy().set_color("#6868B8").scale(1.6),
                    strs.copy().set_color("#4848B8").scale(1.6),
                    strs.copy().set_color("#2828B8").scale(1.6),
                    strs.copy().set_color("#0808B8").scale(1.6),
                )
            if title_2 == "":
                title_2 = (r"{\tiny{\emph{Powered by}:}}\\ ", *PoweredBy)
            title_2 = MobjectOrChars(title_2)
            title_2.set_color(title_2_color).scale(
                title_2_scale).align_on_border(
                    *title_2_position).add_shadow_mobjects(
                        title_2_shadow[0], title_2[title_2_shadow[1]])
            if title_2_extra != "":
                title_2[title_2_extra[0]].set_color(title_2_extra[1]).shift(
                    title_2_extra[2])
            if title_2_indicate_scale_factor == "":
                title_width = mobjs_2.get_width()
                title_2_indicate_scale_factor = (title_width -
                                                 0.5) / title_width
            startscreens.add(
                ShowSubmobjectsOneByOneAndFadeInThenIndicateThenFadeOut(
                    mobjs_2.scale(mobjs_2_scale),
                    title_2,
                    indicate_scale_factor=title_2_indicate_scale_factor,
                    show_rate_func=mobjs_2_rate_func,
                    run_time=mobjs_2_interval * (len(mobjs_2)),
                    **kwargs))
        if title != None or subtitle != None:
            mobjs_3 = [Group(), "", ""]
            if title != None:
                txt_title = TextMobject(title).scale(title_scale)
                if txt_title.get_width() > 14:
                    txt_title.stretch_to_fit_width(14)
                mobjs_3[1] = txt_title.set_color(title_color).to_edge(
                    *title_position)
                mobjs_3[0].add(mobjs_3[1])
            if subtitle != None:
                mobjs_3[0].add(
                    TextMobject(subtitle).set_color(subtitle_color).scale(
                        subtitle_scale).shift(subtitle_position))
            if filename != None and filename != "":
                if reference == None or reference == "":
                    filename_position = reference_position
                mobjs_3[0].add(
                    TextMobject(filename).set_color(filename_color).scale(
                        filename_scale).shift(filename_position))
            if reference != None and reference != "":
                txt_reference = TextMobject(reference).scale(reference_scale)
                if txt_reference.get_width() > 14:
                    txt_reference.stretch_to_fit_width(14)
                mobjs_3[0].add(
                    txt_reference.set_color(reference_color).shift(
                        reference_position))
            if warning != None and warning != "":
                txt_warning = TextMobject(warning).scale(
                    warning_scale)  # height=0.3
                if txt_warning.get_width() > 14:
                    txt_warning.stretch_to_fit_width(14)
                mobjs_3[2] = txt_warning.set_color(warning_color).shift(
                    warning_position)
            animations = AGroup()
            if len(mobjs_3[0]) > 0:
                animations.add(
                    FadeIn(mobjs_3[0],
                           run_time=0.5,
                           scale_factor=1,
                           color=None))
            if len(mobjs_3[1]) > 0:
                animations.add(GrowFromCenter(Underline(mobjs_3[1])))
            if len(mobjs_3[2]) > 0:
                animations.add(
                    FadeInThenIndicate(mobjs_3[2],
                                       run_time=0.5,
                                       scale_factor=1.2,
                                       color=None))
            startscreens.add(
                FadeoutSuccession(AnimationGroup(*animations,
                                                 run_time=mobjes_3_run_time),
                                  run_time=0.05))
        super().__init__(AnimationGroup(*startscreens, lag_ratio=1), **kwargs)
Exemplo n.º 16
0
 def create_circle_shadow(self, width=32, num=50, color=BLUE_A):
     self.shadow = VGroup(*[Circle(radius=self.inner_radius + (i+0.5) * width/100/num, stroke_width=width/num, stroke_color=color,
                                   stroke_opacity=(i-num) ** 2 * 1/num/num, plot_depth=2) for i in range(num+1)]).move_to(self.center)
     self.add(self.shadow)
     return self.shadow
Exemplo n.º 17
0
 def circle_to_mobject(self, circle: se.Circle) -> Circle:
     # svgelements supports `rx` & `ry` but `r`
     mob = Circle(radius=circle.rx)
     mob.shift(_convert_point_to_3d(circle.cx, circle.cy))
     return mob