Минимальный Manim-проект для создания анимации о функции Вейерштрасса:
В анимации показываются формула, основные свойства функции и приближение к выбранной точке графика, чтобы продемонстрировать фрактальную структуру.
main.py- основная сценаDrawFunction.manim.cfg- настройки Manim: вертикальный формат1080x1920, черный фон, частота кадров..gitignore- исключает сгенерированные видео, изображения, папкуmediaи кеш Python.Video/- папка для готовых или промежуточных видеоматериалов, если используется локально.
Нужны Python, Manim и NumPy:
pip install manim numpyДля корректной работы Manim также должны быть установлены системные зависимости Manim: LaTeX, FFmpeg и библиотеки рендеринга. Подробности зависят от операционной системы.
Из корня проекта:
manim -pqh main.py DrawFunctionГде:
-p- открыть результат после рендера;-q h- качествоhigh;main.py- файл со сценой;DrawFunction- имя класса сцены.
Для быстрого тестового рендера можно использовать:
manim -pql main.py DrawFunctionОсновные параметры находятся в начале метода construct в main.py:
a = 0.5,b = 13- параметры функции Вейерштрасса;x0 = 0.52- точка фокусировки;max_terms- число членов ряда для аппроксимации;graph_samples- количество точек графика;max_x_stretch,second_x_stretch- уровни горизонтального масштабирования при приближении.
Частота кадров в коде задается строкой:
config.frame_rate = 60Она переопределяет значение из manim.cfg.
A minimal Manim project for creating an animation of the Weierstrass function:
The animation presents the formula, the function's key properties, and a zoom-in on a selected point of the graph to demonstrate its fractal structure.
main.py— the mainDrawFunctionscene.manim.cfg— Manim configuration: vertical format (1080x1920), black background, and frame rate..gitignore— excludes generated videos, images, themediadirectory, and Python cache files.Video/— directory for finished or intermediate video files, if used locally.
Python, Manim, and NumPy are required:
pip install manim numpyFor Manim to work correctly, its system dependencies must also be installed, including LaTeX, FFmpeg, and rendering libraries. The exact requirements depend on the operating system.
Run the following command from the project root directory:
manim -pqh main.py DrawFunctionWhere:
-p— preview the result after rendering;-q h— usehighquality;main.py— the file containing the scene;DrawFunction— the name of the scene class.
For a quick test render, use:
manim -pql main.py DrawFunctionThe main parameters are defined at the beginning of the construct method in main.py:
a = 0.5,b = 13— parameters of the Weierstrass function;x0 = 0.52— the focal point;max_terms— the number of series terms used for approximation;graph_samples— the number of graph sample points;max_x_stretch,second_x_stretch— horizontal zoom levels used during the zoom-in animation.
The frame rate is set in the code using:
config.frame_rate = 60This overrides the value specified in manim.cfg.
After rendering, Manim saves the video in the media/ directory. This directory is not tracked by Git because it contains generated files.
После рендера Manim сохраняет видео в папке media/. Эта папка не отслеживается Git, так как содержит генерируемые файлы.