ManimFiles:我的Twitter动画代码

  • K2_668505
    了解作者
  • 14KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-07 19:09
    上传日期
ManimFiles:我的Twitter动画代码
ManimFiles-master.zip
  • ManimFiles-master
  • explain_sum.py
    4.5KB
  • multinoulli.py
    2.2KB
  • test.py
    3.5KB
  • exponential.py
    2.7KB
  • expectation.py
    3.4KB
  • pdist.py
    1.7KB
  • gaussian.py
    5.3KB
  • densityfunc.py
    4.9KB
  • barchart.py
    2.9KB
  • sumrule.py
    2KB
  • laplace.py
    4.2KB
内容介绍
from manim import * import numpy as np import math NEW_BLUE = "#68a8e1" class Thumbnail(GraphScene): def __init__(self, **kwargs): self.CONFIG = { "x_min" :0, "x_max": 4, "y_min" :0, # "y_tick_frequency":0.1, "x_tick_frequency":1, "x_axis_width":6, "y_axis_height":4, "exclude_zero_label" :False, "axes_color":GREY, "graph_origin":ORIGIN-2 +LEFT, "x_labeled_nums":[0,2,4] } GraphScene.__init__(self, **self.CONFIG) def construct(self): self.show_function_graph() def show_function_graph(self): self.setup_axes(animate=True) img = ImageMobject('/home/niwhskal/Downloads/Untitled45.png').scale(0.2).to_corner(DR) self.add(img) y_ax = Tex(r"Number\\of\\students $\uparrow$").next_to(self.axes[1], LEFT).scale(0.6) x_ax = Tex(r"GPA $\rightarrow$").next_to(self.axes[0], DOWN).scale(0.6) self.play(Write(y_ax)) self.play(Write(x_ax)) def func(x): return 15*(1/np.sqrt(2*np.pi*1))*(np.exp(-((x-2)**2)/(2*1))) def rect(x): return 2.775*(x-1.5)+3.862 recta = self.get_graph(rect,x_min=0,x_max=4) graph = self.get_graph(func,x_min=0,x_max=4) graph.set_color(NEW_BLUE) input_tracker_p1 = ValueTracker(1.5) input_tracker_p2 = ValueTracker(3.5) def get_x_value(input_tracker): return input_tracker.get_value() def get_y_value(input_tracker): return graph.underlying_function(get_x_value(input_tracker)) def get_x_point(input_tracker): return self.coords_to_point(get_x_value(input_tracker), 0) def get_y_point(input_tracker): return self.coords_to_point(0, get_y_value(input_tracker)) def get_graph_point(input_tracker): return self.coords_to_point(get_x_value(input_tracker), get_y_value(input_tracker)) def get_v_line(input_tracker): return DashedLine(get_x_point(input_tracker), get_graph_point(input_tracker), stroke_width=2) def get_h_line(input_tracker): return DashedLine(get_graph_point(input_tracker), get_y_point(input_tracker), stroke_width=2) kwargs = { "x_min" : 0, "x_max" : 4, "fill_opacity" : 0.75, "stroke_width" : 0.25} self.graph=graph iteraciones=6 self.rect_list = self.get_riemann_rectangles_list( graph, iteraciones,start_color=PURPLE,end_color=ORANGE, **kwargs ) flat_rects = self.get_riemann_rectangles( self.get_graph(lambda x : 0), dx = 0.5,start_color=invert_color(PURPLE),end_color=invert_color(ORANGE),**kwargs ) rects = self.rect_list[0] pop = Tex(r"Student \\ population").scale(0.7).next_to(self.graph, UP*2) self.play(Write(pop)) equalto = Tex("= 100").scale(0.7).next_to(pop, RIGHT) self.play(Write(equalto)) self.transform_between_riemann_rects( flat_rects, rects, replace_mobject_with_target_in_scene = True, run_time=1 ) for j in range(4,6): for w in self.rect_list[j]: color=w.get_color() w.set_stroke(color,1.5) for j in range(1,6): num1 = 1000*j*j eq = Tex("= ", str(num1), color = GREEN).scale(0.7).next_to(pop,RIGHT) self.play(ReplacementTransform(equalto, eq)) self.transform_between_riemann_rects( self.rect_list[j-1], self.rect_list[j], dx=1, replace_mobject_with_target_in_scene = True, run_time=1 ) equalto = eq self.play(ShowCreation(graph)) self.wait(2) y_axNew = Tex(r"probability\\density $\uparrow$").next_to(self.axes[1], LEFT).scale(0.6) self.remove(pop) self.remove(eq) self.remove(equalto) self.play(ReplacementTransform(y_ax, y_axNew)) self.play(ApplyMethod(self.graph.shift, UP)) gau_eqn = Tex("=", "$\\frac{1}{\\sqrt{2\\pi\\sigma^2}}$", "$e^{\\frac{(x-\\mu)^2}{2\\sigma^2}}$").next_to(self.graph, RIGHT) gau_eqn[1][6].set_color(PURPLE_D) gau_eqn[2][4].set_color(BLUE) gau_eqn[2][9].set_color(PURPLE_D) # gau_eqn.set_color_by_tex("$\sigma$", PURPLE_D) self.play(Write(gau_eqn)) self.play(ApplyMethod(self.graph.shift, DOWN)) line1 = self.get_vertical_line_to_graph(2, graph, DashedLine, color = BLUE) dot = Dot(color = BLUE).move_to(self.coords_to_point(2,0)) m_text = Tex(r"$\mu$", color = BLUE).scale(0.8).next_to(dot, UP).shift(RIGHT*0.3) self.play(ShowCreation(line1), ShowCreation(dot), Write(m_text)) setts = { "dash_length": 0.05, "dash_spacing": None, "positive_space_ratio": 0.5, } line_sig = DoubleArrow(self.coords_to_point(1,func(1)), self.coords_to_point(3, func(3)), color = PURPLE_D, **setts) sigtext = Tex(r"$\sigma$", color = PURPLE_D).scale(0.7).next_to(line_sig, UP*0.5).shift(LEFT*0.3) self.play(ShowCreation(line_sig), Write(sigtext)) self.wait(5)
评论
    相关推荐
    • twitter启动页动画
      类似twitter启动页的动画源码 先将启动图片换成一张静态图片,之后再加载动画
    • TwitterBirdAnimation, Twitter 动画的复制,当应用程序启动时出现.zip
      TwitterBirdAnimation, Twitter 动画的复制,当应用程序启动时出现 TwitterBirdAnimation复制 Twitter 缩放动画动画阅读随附博客文章。
    • Twitter爱心点赞动画效果代码.zip
      Twitter爱心点赞动画效果代码基于jquery-1.11.0.min.js制作,点击红心按钮动画特效,同时点赞次数加一。
    • double_pendulum:随机双摆的动画
      Twitter机器人背后的代码,该动画发布了一个双摆的动画,该动画从一个随机位置释放了30秒。 基本用法 要创建一个随机双摆的动画: >> > from simulation import create_random_example , simulate >> > from ...
    • 仿twitter弹出登录窗口
      仿twitter弹出登录窗口,弹性弹出效果仿动画
    • Twitter爱心点赞动画效果特效代码
      Twitter爱心点赞动画效果代码基于jquery-1.11.0.min.js制作,点击红心按钮动画特效,同时点赞次数加一。
    • 仿twitter动画
      仿twitter动画,app开场动画
    • SVG实现镂空动画图标特效代码
      SVG实现镂空动画图标是一款基于SVG的镂空动画图标,图标的绘制是通过SVG的path标签实现的,本示例展示3个不同的东西,篮球、twitter logo和一个猪头。鼠标滑过图标时,图标镂空的部分将会以渐变的方式填充一种颜色,...
    • SVG实现镂空动画图标.zip
      SVG实现镂空动画图标是一款基于SVG的镂空动画图标,图标的绘制是通过SVG的path标签实现的,本示例展示3个不同的东西,篮球、twitter logo和一个猪头。鼠标滑过图标时,图标镂空的部分将会以渐变的方式填充一种颜色,...
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
      guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档