Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20260810_bezier.py
Last active August 10, 2026 17:32
[Bezier racing] Two Bezier curves on a path. #manim #animation #bezier #updater
from manim import *
class Bezier(VGroup):
def __init__(self, start, handle1, handle2, end, **kwargs):
super().__init__(**kwargs)
self.curve = VMobject(stroke_color=ORANGE,stroke_width=4)
self.start = Circle(arc_center=start, color=RED, radius=0.08, fill_opacity=0.7)
self.end = Circle(arc_center=end, color=BLUE, radius=0.08, fill_opacity=0.7)
self.handle1 = Circle(arc_center=handle1, color=RED, radius=0.05, fill_opacity=0.0)
self.handle2 = Circle(arc_center=handle2, color=BLUE, radius=0.05, fill_opacity=0.0)
self.hline1 = VMobject()
@uwezi
uwezi / 20260806_look.py
Last active August 6, 2026 13:55
[3D objects face camera] Lets objects automatically face the camera. #manim #3D #threedscene #updater
from manim import *
from scipy.spatial.transform import Rotation as Rot
class look_to_camera(ThreeDScene):
def construct(self):
ax = ThreeDAxes()
self.add(ax)
obj = VGroup(
Text("Hello world!"),
Line(ORIGIN, OUT, stroke_width=0, stroke_opacity=0),
@uwezi
uwezi / 20260626_compass.py
Last active June 26, 2026 22:33
[Compass] A compass mobject for Manim. #manim #geometry
class Compass(VGroup):
def __init__(self, arm_length=3, arm_width=.2, angle=15*DEGREES, left_color=RED, right_color=YELLOW,):
super().__init__()
self.left_arm = Polygon(
[0,0,0],[0,arm_length,0],[-arm_width,arm_length,0],[-arm_width,arm_width,0],
stroke_width=0,
fill_color=left_color,
fill_opacity=1
)
self.right_arm = Polygon(
@uwezi
uwezi / 20260617_kicad.py
Last active June 17, 2026 12:55
[SVG import from KiCAD] Importing schematic drawings into Manim. #manim #svg #electronics #kicad
from manim import *
class kicadSVGImport(Scene):
def construct(self):
self.camera.background_color=WHITE
self.add(NumberPlane())
svg = SVGMobject("bilder/20260617_manim_test.svg").scale_to_fit_height(6)
svg.set_stroke(width=2)
self.add(svg)
config.frame_rate=1
@uwezi
uwezi / 20260605_explode.py
Last active June 5, 2026 07:58
[exploding text] Splitting text into small pieces and explode. #manim #text #animation #visualeffect
class Explosion(Scene):
def construct(self):
# make a single object of your text
text = Union(*Text("Hello World", font_size=100)).set_stroke(width=0).set_fill(opacity=1)
self.add(text)
delta = 0.1
pieces = VGroup(
Intersection(text, Square(side_length=delta).move_to([x,y,0])).set_stroke(width=0).set_fill(opacity=1)
for x in np.arange(text.get_left()[0],text.get_right()[0]+delta,delta)
for y in np.arange(text.get_bottom()[1],text.get_top()[1]+delta,delta)
@uwezi
uwezi / 20260419_radioactive.py
Last active April 19, 2026 20:03
[Radioactive decay] Simulating radioactive decay. #manim #physics #simulate #radioactive
from manim import *
class Atom(Dot):
def __init__(self, pos=ORIGIN, color = RED, prob = 0.1):
super().__init__(point=pos, radius=.07, stroke_width=0, fill_opacity=1, color=color)
self.prob = prob
self.add_updater(self.updater)
def updater(self,mobj,dt):
if (self.prob > 0) and (np.random.uniform(0,1) <= self.prob*dt):
self.prob = 0
@uwezi
uwezi / 20260417_mandala.py
Last active April 17, 2026 12:23
[Mandala] Drawing a mandala. #manim #geometry #bezier
from manim import *
class manadala(Scene):
def construct(self):
center = Dot()
tri = RegularPolygon(n=3, radius=0.5).rotate(PI, about_point=ORIGIN)
circ = Circle(radius = 1)
petarc = VMobject().set_anchors_and_handles(
[np.cos(PI/8),np.sin(PI/8),0],
[1.5*np.cos(PI/8),1.5*np.sin(PI/8),0],
@uwezi
uwezi / 20260415_tile.py
Last active April 15, 2026 18:13
[optimal tiling?] Is this the optimal tiling of an area? #manim #geometry
class tile(Scene):
def construct(self):
for _ in range(10):
# Size rectangleSize = new Size(); # rectangle size will be used as a default value that is the exact aspect ratio desired.
#
# Aspect Ratio = h / w
# where h is the height of the child and w is the width
#
# the numerator will be the aspect ratio and the denominator will always be one
# if you want it to be square just use an aspect ratio of 1
@uwezi
uwezi / 20260407_orbit.py
Last active April 7, 2026 19:54
[Planetary orbits] Orbit simulation. #manim #animation #simulation #newton #planet #physics #orbit
class Planet(VMobject):
def __init__(self,
sun:VMobject=None,
ax:CoordinateSystem=None,
color = BLUE,
radius =0.1,
mass = 6e24,
pos = np.array([150e9,0,0]),
vel = np.array([0,30e3,0]),
G = 6.67e-11,
@uwezi
uwezi / 20260403_sound.py
Created April 3, 2026 18:50
[create sound] Create a tone and play it in Manim. #manim #audio #wav #sound
import wave
import struct
class increaseFreq(Scene):
def construct(self):
fsamp = 44.1e3
f0 = 440
f1 = 880
time = 3
ts = np.linspace(start = 0, stop = time, num=int(fsamp*time))
def f(t):