✔️ Requisitos iniciais:
-
- Baixe o FFmpeg e adicione a pasta
/bin
nas variáveis de ambiente do sistema. <ffmpeg.org/download> - Instale o Manin:
pip install manim
- Baixe e instale o MiKTeX. <miktex.org/download/>
- Baixe o FFmpeg e adicione a pasta
✔️ Eu pedi para o ChatGPT gerar o vídeo já no formato de story do Instagram:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
from manim import * import numpy as np class FourierSeries(Scene): def construct(self): # Definir os eixos com área do gráfico menor axes = Axes( x_range=[0, 2 * np.pi, np.pi / 2], y_range=[-2, 2, 1], x_length=4, # Largura do gráfico y_length=6, # Altura do gráfico axis_config={"color": BLUE}, ).shift(LEFT * 1) # Etiquetas dos eixos x_label = axes.get_x_axis_label(Tex("x"), edge=RIGHT, direction=RIGHT) y_label = axes.get_y_axis_label(Tex("y"), edge=UP, direction=UP) # Onda quadrada original (alvo da Transformada de Fourier) com cor suave square_wave = axes.plot( lambda x: 1 if (x % (2 * np.pi)) < np.pi else -1, color=YELLOW_B, # Cor mais suave stroke_width=3 ) # Somatório progressivo de senos para aproximar a onda quadrada com cor suave approx_wave = axes.plot(lambda x: 0, color=GREEN_B, stroke_width=3) # Mostrar os eixos e as etiquetas self.play(Create(axes), Write(x_label), Write(y_label)) # Mostrar a onda quadrada original self.play(Create(square_wave)) self.wait(1) # Parâmetros de Fourier num_terms = 10 # Número de termos da série de Fourier wave_sum = lambda x, n: sum( (4 / (np.pi * (2 * k - 1))) * np.sin((2 * k - 1) * x) for k in range(1, n + 1) ) # Animação: mostrar a aproximação da série de Fourier for n in range(1, num_terms + 1): new_wave = axes.plot(lambda x: wave_sum(x, n), color=GREEN_B, stroke_width=3) term_text = Text(f"{n} termos", font_size=24).to_edge(UP).shift(UP * 0.5) # Traz para frente equation = MathTex( r"S_n(x) = \sum_{k=1}^{%d} \frac{4}{\pi(2k-1)} \sin((2k-1)x)" % n, font_size=28 ).next_to(term_text, DOWN, buff=0.2) # Coloca abaixo do texto # Animação self.play(Transform(approx_wave, new_wave), Write(term_text), Write(equation)) self.wait(1) self.remove(term_text, equation) # Manter a onda final por um tempo self.wait(2) # Para renderizar com a resolução desejada, utilize: # manim -pql fourier_series.py FourierSeries -r 1080,1920 |
✔️ Salvei o código com o nome fourier_series.py
e utilizei o comando manim -pql fourier_series.py FourierSeries -r 1080,1920
para executá-lo no prompt do Windows.
A saída do comando foi esta:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
C:\Users\helioandrade\Desktop>manim -pql fourier_series.py FourierSeries -r 1080,1920 Manim Community v0.18.1 [10/22/24 14:31:33] INFO Writing x to media\Tex\3e7d1d2bb908bbaa.tex tex_file_writing.py:109 latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:02] INFO Writing y to media\Tex\5aefc11ea31a6f78.tex tex_file_writing.py:109 latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:03] INFO Animation 0 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\4060174042_2485400292_223132457.mp4' [10/22/24 14:32:04] INFO Animation 1 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_490827631_3139261652.mp4' INFO Animation 2 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_992881071.mp4' INFO Writing S_n(x) = \sum_{k=1}^{1} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\70879cf05ec9c84d.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:07] INFO Animation 3 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_64539594_4233549398.mp4' INFO Animation 4 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_3695567569.mp4' INFO Writing S_n(x) = \sum_{k=1}^{2} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\6763164500e67124.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:09] INFO Animation 5 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_2944990281_3887877940.mp4' [10/22/24 14:32:10] INFO Animation 6 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_996295284.mp4' INFO Writing S_n(x) = \sum_{k=1}^{3} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\42810a5d55d7389b.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:12] INFO Animation 7 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3569064079_4293569388.mp4' INFO Animation 8 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_4188531010.mp4' INFO Writing S_n(x) = \sum_{k=1}^{4} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\2ed38653ec701e74.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:15] INFO Animation 9 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3070398158_2909142482.mp4' INFO Animation 10 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_1591958658.mp4' INFO Writing S_n(x) = \sum_{k=1}^{5} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\7f318c3c1d25fc17.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:17] INFO Animation 11 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3781713892_1403206725.mp4' INFO Animation 12 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_3048416019.mp4' INFO Writing S_n(x) = \sum_{k=1}^{6} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\c41044732064ade6.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:20] INFO Animation 13 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_1369283193_136478819.mp4' INFO Animation 14 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_3669888293.mp4' INFO Writing S_n(x) = \sum_{k=1}^{7} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\fcf931c3bbfc0e80.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:22] INFO Animation 15 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_1037128414_3554922580.mp4' [10/22/24 14:32:23] INFO Animation 16 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_2687453153.mp4' INFO Writing S_n(x) = \sum_{k=1}^{8} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\6aa38bb8d01f1dfc.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:25] INFO Animation 17 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_2749268059_4214835693.mp4' INFO Animation 18 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\par tial_movie_files\FourierSeries\2498110781_3890345977_1896101905.mp4' INFO Writing S_n(x) = \sum_{k=1}^{9} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to tex_file_writing.py:109 media\Tex\5c59d830befbaa7d.tex latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:27] INFO Animation 19 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\partial_movie_files\FourierSeries\2498110781_1297628033_1800758859.mp4' [10/22/24 14:32:28] INFO Animation 20 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\partial_movie_files\FourierSeries\2498110781_3890345977_1878957989.mp4' INFO Writing S_n(x) = \sum_{k=1}^{10} \frac{4}{\pi(2k-1)} \sin((2k-1)x) to media\Tex\d0653e001a8cc5aa.tex tex_file_writing.py:109 latex: security risk: running with elevated privileges dvisvgm: security risk: running with elevated privileges [10/22/24 14:32:30] INFO Animation 21 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\partial_movie_files\FourierSeries\2498110781_2233300470_2445556570.mp4' INFO Animation 22 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\partial_movie_files\FourierSeries\2498110781_3890345977_2728153465.mp4' [10/22/24 14:32:31] INFO Animation 23 : Partial movie file written in scene_file_writer.py:527 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\partial_movie_files\FourierSeries\2498110781_1141282389_67615400.mp4' INFO Combining to Movie file. scene_file_writer.py:617 INFO scene_file_writer.py:737 File ready at 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\FourierSeries.mp4' INFO Rendered FourierSeries scene.py:247 Played 24 animations INFO Previewed File at: 'C:\Users\helioandrade\Desktop\media\videos\fourier_series\1920p15\FourierSeries.mp4' file_ops.py:231 C:\Users\helioandrade\Desktop> |
✔️ Peguei o vídeo produzido e editei, adicionando uma música. O resultado foi este:
*Atualizado em 30 de outubro de 2024