360macky / generative-manim

🎨 GPT for video generation ⚡️
https://generative-manim.vercel.app
Apache License 2.0
250 stars 44 forks source link

Generation of scenes mixing via API in high traffic #23

Open 360macky opened 4 weeks ago

360macky commented 4 weeks ago

In some cases, the scenes returned by the API can be mixed when there are multiple requests.

Example:

image

Code:

class GraphArrow(Scene):
    def construct(self):
        # Create axes and labels
        axes = Axes(x_range=[0, 10], y_range=[0, 10])
        x_label = MathTex(r'\text{Espaço}').scale(0.575)
        y_label = MathTex(r'\text{Tempo}').scale(0.75)
        labels = VGroup(x_label.next_to(axes.x_axis, RIGHT), y_label.next_to(axes.y_axis, UP))

        # Create dots
        d = Dot(color=WHITE, radius=0.1)
        d.move_to([0, 0, 0])
        d2 = Dot(color=WHITE, radius=0.1)
        d2.move_to([-1, 0, 0])

        # Group dots
        g = VGroup(d, d2)
        g.arrange()

        # Create traced paths
        trace = VMobject()
        trace2 = VMobject()

        trace_points = []
        trace2_points = []

        def update_trace(trace):
            trace_points.append(d.get_center())
            if len(trace_points) > 1:
                new_path = DashedVMobject(Line(trace_points[-2], trace_points[-1]), num_dashes=1, equal_lengths=True)
                trace.add(new_path)

        def update_trace2(trace2):
            trace2_points.append(d2.get_center())
            if len(trace2_points) > 1:
                new_path = DashedVMobject(Line(trace2_points[-2], trace2_points[-1]), num_dashes=1, equal_lengths=True)
                trace2.add(new_path)

        trace.add_updater(update_trace)
        trace2.add_updater(update_trace2)

        # Add elements to the scene
        self.play(Write(axes), Write(labels))
        self.add(d, d2, trace, trace2)
        self.wait(2)
        self.play(d.animate.move_to([0, 3, 0]), d2.animate.move_to([0, 2, 0]))
        self.wait(2)
        self.play(d.animate.move_to([0, -3, 0]), d2.animate.move_to([0, -2, 0]))
        self.wait(2)
        trace.clear_updaters()
        trace2.clear_updaters()

Video:

https://github.com/360macky/generative-manim/assets/47821093/54bb2379-ace8-4e9d-a8df-694ec4b7b8be