Advertisement
EXTREMEXPLOIT

Animation Script

Apr 18th, 2021
1,663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.46 KB | None | 0 0
  1. from manim import *
  2.  
  3. PixelWidth = config.pixel_width = 1920
  4. PixelHeight = config.pixel_height = 1080
  5. FPS = config.frame_rate = 60
  6.  
  7. N = 10
  8. X, Y = (0, N, 1), (0, N, 1)
  9.  
  10. def RandomPosition():
  11.     ScreenX, ScreenY = np.arange(-7, 7, 0.25), np.arange(-3.9, 3.9, 0.25)
  12.     np.random.seed()
  13.     return np.array((np.random.choice(ScreenX), np.random.choice(ScreenY), 0))
  14.  
  15. class MainScene(GraphScene):
  16.     def __init__(self, **kwargs):
  17.         GraphScene.__init__(self,
  18.         x_min = X[0]+1,
  19.         x_max = X[1],
  20.         y_min = Y[0],
  21.         y_max = Y[1],
  22.         y_tick_frequency = X[2],
  23.         x_tick_frequency = Y[2],
  24.         x_axis_width = 15,
  25.         x_label_direction = DOWN,
  26.         y_label_direction = UP,
  27.         x_axis_visibility = True,
  28.         y_axis_visibility = True,
  29.         graph_origin = np.array([-7.1, -4, 0]),
  30.         x_axis_label = '',
  31.         y_axis_label = '')
  32.  
  33.     def construct(self):
  34.  
  35.         Title = Tex("Y AHORA QUÉ?").to_edge(UP).scale(2).shift(0.2*RIGHT)
  36.         ReverseInterrogant = Tex("?").scale(2).rotate(DEGREES*180).next_to(Title, LEFT, buff=0).shift(0.025*DOWN)
  37.  
  38.         self.add(Title, ReverseInterrogant)
  39.  
  40.         BinaryBlocks = []
  41.         Blocks = 4
  42.         DigitsPerBlock = 50
  43.         for i in range(Blocks):
  44.             BinaryString = ""
  45.             for j in range(DigitsPerBlock):
  46.                 BinaryString += str(np.random.choice([0, 1]))
  47.             Binary = Tex(BinaryString).to_edge(UP).shift(2*(i+1)*(.85*DOWN)).set_opacity(0.20)
  48.             self.bring_to_back(Binary)
  49.             self.add(Binary)
  50.             BinaryBlocks.append(Binary)
  51.  
  52.         self.setup_axes(animate=False)
  53.  
  54.         MyGraph1 = self.get_graph(lambda x: np.log(x**2), color=GREEN, x_min=1, x_max=N, stroke_opacity=0.5, stroke_width=5)
  55.         MyGraph2 = self.get_graph(lambda x: 2*np.cos(.5*x)+8, color=RED, x_min=1, x_max=N, stroke_opacity=0.5, stroke_width=5)
  56.         MyGraph3 = self.get_graph(lambda x: np.sqrt(x), color=ORANGE, x_min=1, x_max=N, stroke_opacity=0.5, stroke_width=5)
  57.         MyGraph4 = self.get_graph(lambda x: x + np.tan(np.sin(x)), color=BLUE, x_min=1, x_max=N, stroke_opacity=0.5, stroke_width=5)
  58.  
  59.         GeneralRelativity = MathTex(r"G_{\mu v}=8\pi G\left(T_{\mu v}+\rho _{\lambda \cdot }g_{\mu \:v}\right)")
  60.         GeneralRelativity.scale(1/2).to_corner(UL, buff=0.25).set_opacity(1/2)
  61.  
  62.         CalculusTheorem = MathTex(r"\int _a^bf\:'\left(x\right)dx=F\left(b\right)-F\left(a\right)")
  63.         CalculusTheorem.scale(1/2).next_to(GeneralRelativity, 1.5*DOWN).set_opacity(1/2)
  64.  
  65.         EulerIdentity = MathTex(r"""P(x) = \frac{1}{{\sigma \sqrt {2\pi } }}e^{{{ - \left( {x - \mu } \right)^2 }
  66.        \mathord{\left/ {\vphantom {{ - \left( {x - \mu } \right)^2 } {2\sigma ^2 }}} \right. \kern-\nulldelimiterspace} {2\sigma ^2 }}}""")
  67.         EulerIdentity.scale(1/2).to_corner(UR, buff=0.25).set_opacity(1/2)
  68.  
  69.         EulerEquation = MathTex(r"\left(x^{2}+y^{2}-1\right)^{3}=x^{2}y^{3}")
  70.         EulerEquation.scale(1/2).next_to(EulerIdentity, DOWN).set_opacity(1/2)
  71.  
  72.         self.play(Write(GeneralRelativity), Write(CalculusTheorem), Write(EulerIdentity), Write(EulerEquation), Write(MyGraph1), Write(MyGraph2), Write(MyGraph3), Write(MyGraph4), run_time=10)
  73.  
  74.         self.wait(60)
  75.  
  76.         self.play(Uncreate(GeneralRelativity), Uncreate(CalculusTheorem), Uncreate(EulerIdentity), Uncreate(EulerEquation), Uncreate(MyGraph1), Uncreate(MyGraph2), Uncreate(MyGraph3), Uncreate(MyGraph4), run_time=10)
  77.  
  78.         self.wait()
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement