From ed534429428f165b2f9abf350366e154490215c5 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Thu, 25 May 2023 12:39:41 +0800 Subject: [PATCH] up --- crazy_functions/数学动画生成manim.py | 40 +++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/crazy_functions/数学动画生成manim.py b/crazy_functions/数学动画生成manim.py index 843c98f..9bb4d01 100644 --- a/crazy_functions/数学动画生成manim.py +++ b/crazy_functions/数学动画生成manim.py @@ -86,7 +86,7 @@ def 动画生成(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt llm_kwargs=llm_kwargs, chatbot=chatbot, history=demo, sys_prompt= r"Write a animation script with 3blue1brown's manim. "+ - r"Please begin with `from manim import *` and name the class as `MyAnimation`. " + + r"Please begin with `from manim import *`. " + r"Answer me with a code block wrapped by ```." ) chatbot.append(["开始生成动画", "..."]) @@ -106,8 +106,8 @@ def examples_of_manim(): ``` -# Moving Group To Destination -class MyAnimation(Scene): + +class MovingGroupToDestination(Scene): def construct(self): group = VGroup(Dot(LEFT), Dot(ORIGIN), Dot(RIGHT, color=RED), Dot(2 * RIGHT)).scale(1.4) dest = Dot([4, 3, 0], color=YELLOW) @@ -119,8 +119,8 @@ class MyAnimation(Scene): ``` -# Plot function and moving framebox -class MyAnimation(Scene): + +class LatexWithMovingFramebox(Scene): def construct(self): text=MathTex( "\\frac{d}{dx}f(x)g(x)=","f(x)\\frac{d}{dx}g(x)","+", @@ -143,8 +143,8 @@ class MyAnimation(Scene): ``` -# Point With Trace -class MyAnimation(Scene): + +class PointWithTrace(Scene): def construct(self): path = VMobject() dot = Dot() @@ -161,5 +161,31 @@ class MyAnimation(Scene): self.play(dot.animate.shift(LEFT)) self.wait() +``` + +``` + +# do not use get_graph, this funciton is deprecated + +class ExampleFunctionGraph(Scene): + def construct(self): + cos_func = FunctionGraph( + lambda t: np.cos(t) + 0.5 * np.cos(7 * t) + (1 / 7) * np.cos(14 * t), + color=RED, + ) + + sin_func_1 = FunctionGraph( + lambda t: np.sin(t) + 0.5 * np.sin(7 * t) + (1 / 7) * np.sin(14 * t), + color=BLUE, + ) + + sin_func_2 = FunctionGraph( + lambda t: np.sin(t) + 0.5 * np.sin(7 * t) + (1 / 7) * np.sin(14 * t), + x_range=[-4, 4], + color=GREEN, + ).move_to([0, 1, 0]) + + self.add(cos_func, sin_func_1, sin_func_2) + ``` """ \ No newline at end of file