first commit
This commit is contained in:
commit
a430ca2bce
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
.PHONY: all preview render opengl venv
|
||||
all: preview
|
||||
|
||||
preview: main.py
|
||||
manim render main.py -pqm
|
||||
|
||||
render: main.py
|
||||
manim render main.py -qh
|
||||
|
||||
opengl: main.py
|
||||
manim render main.py -p --renderer=opengl
|
||||
|
||||
venv: requirements.txt
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements
|
64
main.py
Normal file
64
main.py
Normal file
@ -0,0 +1,64 @@
|
||||
from manim import *
|
||||
import math
|
||||
|
||||
def norm(vec):
|
||||
return math.sqrt(sum([xi ** 2 for xi in vec]))
|
||||
|
||||
def normalize(vec):
|
||||
n = norm(vec)
|
||||
return [xi / n for xi in vec]
|
||||
|
||||
def plus(v1, v2):
|
||||
return [x1 + x2 for x1, x2 in zip(v1, v2)]
|
||||
|
||||
def minus(v1, v2):
|
||||
return [x1 - x2 for x1, x2 in zip(v1, v2)]
|
||||
|
||||
def mult(v, c):
|
||||
return [xi * c for xi in v]
|
||||
|
||||
def SegmentedLine(points):
|
||||
assert(len(points) >= 2)
|
||||
ret = []
|
||||
for p1, p2 in zip( points[:-1], points[1:] ):
|
||||
vec = minus(p2, p1)
|
||||
length = norm(vec)
|
||||
normalized = normalize(vec)
|
||||
rotated = [-normalized[1], normalized[0], 0]
|
||||
|
||||
ret.append(p1)
|
||||
ret.append(plus(p1, mult(normalized, length * 1/3)))
|
||||
ret.append(plus(p1, plus(mult(normalized, length/2), mult(rotated, math.sqrt(3) * length / 6))))
|
||||
ret.append(plus(p1, mult(normalized, length * 2/3)))
|
||||
ret.append(points[-1])
|
||||
return ret
|
||||
|
||||
class snowflake(Scene):
|
||||
def construct(self):
|
||||
|
||||
points = [[-7, -1, 0],
|
||||
[ 7, -1, 0]]
|
||||
|
||||
segment = VMobject(stroke_width=1)
|
||||
segment.set_points_as_corners(points)
|
||||
|
||||
self.add(*[Dot(p) for p in points])
|
||||
|
||||
self.play(Create(segment))
|
||||
self.wait(1)
|
||||
|
||||
vg = VGroup()
|
||||
for i in range(3):
|
||||
points = SegmentedLine(points)
|
||||
vg.add(*[Dot(p) for p in points])
|
||||
self.play(Create(vg))
|
||||
self.play(segment.animate.set_points_as_corners(points))
|
||||
self.wait(1)
|
||||
|
||||
self.play(Uncreate(vg))
|
||||
self.play(*[FadeOut(mob) for mob in self.mobjects])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sc = snowflake()
|
||||
sc.render(True)
|
8
manim.cfg
Normal file
8
manim.cfg
Normal file
@ -0,0 +1,8 @@
|
||||
[CLI]
|
||||
frame_rate = 30
|
||||
pixel_height = 1080
|
||||
pixel_width = 1920
|
||||
background_color = BLACK
|
||||
background_opacity = 1
|
||||
scene_names = snowflake
|
||||
|
48
requirements.txt
Normal file
48
requirements.txt
Normal file
@ -0,0 +1,48 @@
|
||||
asttokens==3.0.0
|
||||
audioop-lts==0.2.1
|
||||
av==13.1.0
|
||||
beautifulsoup4==4.13.3
|
||||
click==8.1.8
|
||||
cloup==3.0.6
|
||||
dearpygui==2.0.0
|
||||
decorator==5.2.1
|
||||
executing==2.2.0
|
||||
glcontext==3.0.0
|
||||
ipython==9.0.1
|
||||
ipython_pygments_lexers==1.1.1
|
||||
isosurfaces==0.1.2
|
||||
jedi==0.19.2
|
||||
manim==0.19.0
|
||||
ManimPango==0.6.0
|
||||
mapbox_earcut==1.0.3
|
||||
markdown-it-py==3.0.0
|
||||
matplotlib-inline==0.1.7
|
||||
mdurl==0.1.2
|
||||
moderngl==5.12.0
|
||||
moderngl-window==3.1.1
|
||||
networkx==3.4.2
|
||||
numpy==2.2.3
|
||||
parso==0.8.4
|
||||
pexpect==4.9.0
|
||||
pillow==11.1.0
|
||||
prompt_toolkit==3.0.50
|
||||
ptyprocess==0.7.0
|
||||
pure_eval==0.2.3
|
||||
pycairo==1.27.0
|
||||
pydub==0.25.1
|
||||
pyglet==2.1.3
|
||||
pyglm==2.8.0
|
||||
Pygments==2.19.1
|
||||
rich==13.9.4
|
||||
scipy==1.15.2
|
||||
screeninfo==0.8.1
|
||||
skia-pathops==0.8.0.post2
|
||||
soupsieve==2.6
|
||||
srt==3.5.3
|
||||
stack-data==0.6.3
|
||||
svgelements==1.9.6
|
||||
tqdm==4.67.1
|
||||
traitlets==5.14.3
|
||||
typing_extensions==4.12.2
|
||||
watchdog==6.0.0
|
||||
wcwidth==0.2.13
|
Loading…
x
Reference in New Issue
Block a user