コード例 #1
0
    def construct(self):
        circle = Circle(color=PURPLE_A)

        square = Square(fill_color=GOLD_B, fill_opacity=1, color=GOLD_A)
        square.move_to(UP + LEFT)

        circle.surround(square)

        rectangle = Rectangle(height=2, width=3)

        ellipse = Ellipse(width=3, height=1, color=RED)
        ellipse.shift(2 * DOWN + 2 * RIGHT)

        pointer = CurvedArrow(2 * RIGHT, 5 * RIGHT, color=MAROON_C)

        arrow = Arrow(LEFT, UP)
        arrow.next_to(circle, DOWN + LEFT)

        rectangle.next_to(arrow, DOWN + LEFT)

        circle2 = Circle()
        circle2.surround(rectangle, buffer_factor=1)

        ring = Annulus(inner_radius=.5, outer_radius=1, color=BLUE)
        ring.next_to(ellipse, RIGHT)

        self.add(pointer)
        self.add(circle2)
        self.play(FadeIn(square))
        self.play(Rotating(square), FadeIn(circle))
        self.play(GrowArrow(arrow))
        self.play(GrowFromCenter(rectangle), GrowFromCenter(ellipse),
                  GrowFromCenter(ring))

        self.wait()
コード例 #2
0
    def create_cicles(self, color=BLUE_A):

        circle_01 = Circle(radius=self.inner_radius, stroke_width=12, stroke_color=color, plot_depth=2.5)
        circle_02 = Circle(radius=self.inner_radius - 0.15, stroke_width=4, stroke_color=color, plot_depth=2.5)
        self.circles = VGroup(circle_01, circle_02).move_to(self.center)
        self.add(self.circles)
        return self.circles
コード例 #3
0
ファイル: pi_creature.py プロジェクト: Tarang74/manim
    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)
コード例 #4
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.add(self.pupil)
コード例 #5
0
 def circle_to_mobject(self, circle_element):
     x, y, r = [
         self.attribute_to_float(circle_element.getAttribute(key))
         if circle_element.hasAttribute(key) else 0.0
         for key in ("cx", "cy", "r")
     ]
     return Circle(radius=r).shift(x * RIGHT + y * DOWN)
コード例 #6
0
 def ellipse_to_mobject(self, circle_element):
     x, y, rx, ry = [
         self.attribute_to_float(circle_element.getAttribute(key))
         if circle_element.hasAttribute(key) else 0.0
         for key in ("cx", "cy", "rx", "ry")
     ]
     return Circle().scale(rx * RIGHT + ry * UP).shift(x * RIGHT + y * DOWN)
コード例 #7
0
    def construct(self):
        circle = Circle()
        text = TexMobject(r"\pi")

        self.play(ShowCreation(circle))
        self.play(circle.become, text)
        self.wait()
コード例 #8
0
ファイル: select_sort.py プロジェクト: Migwel/algo-animation
 def build_text_and_circles(value, location):
     text_obj = TextMobject(str(value))
     text_obj.move_to(location)
     circle_obj = Circle()
     circle_obj.surround(text_obj)
     circle_obj.scale(1.5)
     return Node(text_obj, circle_obj, value)
コード例 #9
0
ファイル: ford_circles.py プロジェクト: misaiya1/demo-solara
 def generate_circle_by_fraction(self, p, q):
     radius = 1./(2 * q**2)
     center = self.axes.coords_to_point(p/q, radius)
     circle = Circle(radius = radius, **self.circle_config)
     circle.rotate(-PI/2.)
     circle.move_to(center)
     return circle
コード例 #10
0
 def __init__(self,
              mobjs="",
              mobj=Circle(),
              scale=1,
              shift=[0, 0, 0],
              offset=None,
              run_time=1,
              clear=True,
              **kwargs):
     if offset is None:
         offset = shift
     if mobjs != None:
         if mobjs == "":
             try:
                 mobjs = ImageMobjectGroup(
                     np.char.mod('%01d', range(0, 10)),
                     "sidewayoutput\\sidewayoutput2020yt")
             except:
                 mobjs = ImageMobjectGroup(
                     np.char.mod('%01d', range(9, -1, -1)), "001\\")
     #if mobj!=None:
     t = mobj.update().get_critical_point(
         [-1, 1, 0]) - mobjs.get_critical_point([-1, 1, 0])
     [
         each.add_updater(lambda mob, mob0=mobj: mob.shift(
             mob0.get_critical_point([-1, 1, 0]) - mob.get_critical_point(
                 [-1, 1, 0])).shift(offset)) for each in mobjs
     ]
     if clear:
         mobjs.add(Mobject())
     super().__init__(
         ShowSubmobjectsOneByOne(mobjs.update().scale(scale),
                                 run_time=run_time,
                                 **kwargs), )
コード例 #11
0
    def ellipse_to_mobject(self, circle_element: MinidomElement, style: dict):
        """Creates a stretched Circle VMobject from a SVG <circle> path
        command.

        Parameters
        ----------
        circle_element : :class:`minidom.Element`
            A SVG circle path command.

        style : :class:`dict`
            Style specification, using the SVG names for properties.

        Returns
        -------
        Circle
            A Circle VMobject
        """
        x, y, rx, ry = [
            self.attribute_to_float(circle_element.getAttribute(key))
            if circle_element.hasAttribute(key)
            else 0.0
            for key in ("cx", "cy", "rx", "ry")
        ]
        result = Circle()
        result.stretch(rx, 0)
        result.stretch(ry, 1)
        result.shift(x * RIGHT + y * DOWN)
        return result
コード例 #12
0
    def construct(self):
        axes = ThreeDAxes()
        circle = Circle()

        self.set_camera_orientation(phi=0 * DEGREES)

        self.play(ShowCreation(circle), ShowCreation(axes))
        self.wait()
コード例 #13
0
 def circle_to_mobject(self, circle_element, style):
     x, y, r = (self.attribute_to_float(circle_element.getAttribute(key))
                if circle_element.hasAttribute(key) else 0.0
                for key in ("cx", "cy", "r"))
     return Circle(radius=r,
                   **parse_style(
                       style,
                       self.generate_default_style())).shift(x * RIGHT +
                                                             y * DOWN)
コード例 #14
0
 def add_circle(self):
     circle = Circle(
         radius=np.abs(self.radius),
         stroke_color=self.circle_color,
         stroke_width=1,
     )
     circle.move_to(self.center)
     self.add(circle)
     self.circle = circle
コード例 #15
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)
コード例 #16
0
 def ellipse_to_mobject(self, circle_element, style):
     x, y, rx, ry = (self.attribute_to_float(
         circle_element.getAttribute(key))
                     if circle_element.hasAttribute(key) else 0.0
                     for key in ("cx", "cy", "rx", "ry"))
     result = Circle(**parse_style(style, self.generate_default_style()))
     result.stretch(rx, 0)
     result.stretch(ry, 1)
     result.shift(x * RIGHT + y * DOWN)
     return result
コード例 #17
0
 def add_pupil(self):
     self.pupil = Circle(
         radius=self.pupil_radius,
         fill_color=BLACK,
         fill_opacity=1,
         stroke_width=0,
         sheen=0.0,
         start_angle=90 * DEGREES,
     )
     self.add(self.pupil)
コード例 #18
0
    def __init__(self, value=0, **kwargs):
        digest_config(self, kwargs)
        self.bar = RoundedRectangle(**self.rounded_rect_kwargs)
        self.slider = Circle(**self.circle_kwargs)
        self.slider_axis = Line(start=self.bar.get_bounding_box_point(LEFT),
                                end=self.bar.get_bounding_box_point(RIGHT))
        self.slider_axis.set_opacity(0.0)
        self.slider.move_to(self.slider_axis)

        super().__init__(value, self.bar, self.slider, self.slider_axis,
                         **kwargs)
コード例 #19
0
ファイル: svg_mobject.py プロジェクト: deerajnagothu/manim
 def ellipse_to_mobject(self, circle_element):
     x, y, rx, ry = [
         self.attribute_to_float(circle_element.getAttribute(key))
         if circle_element.hasAttribute(key) else 0.0
         for key in ("cx", "cy", "rx", "ry")
     ]
     result = Circle()
     result.stretch(rx, 0)
     result.stretch(ry, 1)
     result.shift(x * RIGHT + y * DOWN)
     return result
コード例 #20
0
    def construct(self):
        circle = Circle()
        square = Square()

        self.add(circle)
        self.add(square)

        self.play(UpdateFromAlphaFunc(circle, self.update_stuff),
                  UpdateFromAlphaFunc(square, self.update_stuff, rate_func=linear))

        self.wait()
コード例 #21
0
    def construct(self):
        circle = Circle()
        square = Square()
        line = Line((3, 0, 0), (5, 0, 0))
        triangle = Polygon((0, 0, 0), (1, 1, 0), (1, -1, 0))

        self.play(ShowCreation(circle), run_time=5)
        self.play(FadeOut(circle), GrowFromCenter(square))
        self.add(line)
        self.play(Transform(square, triangle))
        self.play(Transform(triangle))
        self.wait()
コード例 #22
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,
                            submobject_mode="all_at_once",
                        ),
                        *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()
コード例 #23
0
    def construct(self):
        circle = Circle()
        square = Square()
        line = Line(np.array([3, 0, 0]), np.array([5, 0, 0]))
        triangle = Polygon(np.array([0, 0, 0]), np.array([1, 1, 0]),
                           np.array([1, -1, 0]))

        self.add(line)
        self.play(ShowCreation(circle))
        self.play(FadeOut(circle))
        self.play(GrowFromCenter(square))
        self.play(Transform(square, triangle))
        self.wait()
コード例 #24
0
    def __init__(self, **kwargs):
        circle = Circle(color=WHITE)
        ticks = []
        for x in range(12):
            alpha = x / 12.
            point = complex_to_R3(np.exp(2 * np.pi * alpha * complex(0, 1)))
            length = 0.2 if x % 3 == 0 else 0.1
            ticks.append(Line(point, (1 - length) * point))
        self.hour_hand = Line(ORIGIN, 0.3 * UP)
        self.minute_hand = Line(ORIGIN, 0.6 * UP)
        # for hand in self.hour_hand, self.minute_hand:
        #     #Balance out where the center is
        #     hand.add(VectorizedPoint(-hand.get_end()))

        VGroup.__init__(self, circle, self.hour_hand, self.minute_hand, *ticks)
コード例 #25
0
def set_up_the_bubbles(
        coordinates_at_a_time,
        Rdata_at_a_time,
        axes,
        color_mat,
        mode='multiples'  #  can be single or multiples
):

    # the argument coordinates_at_a_time and Rdata_at_a_time is
    # just one column in coordinates and Rdata
    # specifically coordinates_at_a_time = coordinates[:,0]
    # Rdata_at_a_time = Rdata[:,0]

    if mode == "multiples":
        #dimension check

        assert (coordinates_at_a_time.shape[0] == Rdata_at_a_time.shape[0]
                )  # and len(color_mat))
        assert (len(coordinates_at_a_time.shape) == 2)
        assert (isinstance(color_mat, list))

        bubbles = VGroup()
        for i, bubbledata in enumerate(
                zip(coordinates_at_a_time, Rdata_at_a_time)):
            bubbles.add(
                Circle(radius=bubbledata[1],
                       color=color_mat[i],
                       fill_opacity=FILL_OPACITY).shift(bubbledata[0]))

    if mode == 'single':

        bubbles = Circle(
            radius=Rdata_at_a_time, color=color_mat,
            fill_opacity=FILL_OPACITY).shift(coordinates_at_a_time)

    return bubbles
コード例 #26
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)
コード例 #27
0
 def __init__(self, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **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)
コード例 #28
0
ファイル: specialized.py プロジェクト: shuchi54/Reducible
 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.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)
     LaggedStart.__init__(self, ApplyMethod, circles, lambda c:
                          (c.restore, ), **kwargs)
コード例 #29
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
コード例 #30
0
    def construct(self):
        circle = Circle(color=YELLOW).scale(self.radius)

        points = []
        lines = []
        for point in range(self.points):
            start_angle = (point / self.points) * 2 * np.pi
            start_point = (RIGHT * np.cos(start_angle) + UP * np.sin(start_angle)) * self.radius
            points.append(start_point)

            stop_angle = (point + point * self.step) / self.points * 2 * np.pi
            stop_point = (RIGHT * np.cos(stop_angle) + UP * np.sin(stop_angle)) * self.radius
            lines.append(Line(start_point, stop_point, **self.line_config))

        self.play(ShowCreation(circle))
        self.wait()

        points_group = VGroup(*[Dot(point, **self.dot_config) for point in points])
        lines_group = VGroup(*lines)

        # self.play(ShowCreation(points_group), run_time=2)
        self.play(ShowCreation(lines_group), run_time=10, rate_func=linear)
        self.wait()