Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20251025_tikz.py
Last active October 27, 2025 16:16
[Tikz and XeLaTeX] Rednering Tikz code using XeLaTeX in Manim. #manim #latex #xelatex #dvisvgm #tikz
from manim import *
class tikztest(Scene):
def construct(self):
MyTexTemplate = TexTemplate(
tex_compiler="xelatex",
output_format=".xdv",
documentclass=r"\documentclass[preview,dvisvgm]{standalone}"
)
MyTexTemplate.add_to_preamble(r"\usepackage{tikz}")
@uwezi
uwezi / 20251015_linefrompoints.py
Last active October 15, 2025 18:22
[Line from points] Creating a line from a list of vertices. #manim #line #radius #rounded #tip
from manim import *
import manim.mobject.geometry.tips as tips
class LineFromPoints(Line):
def __init__(self, pointsdirections, radius=0, **kwargs):
super().__init__(**kwargs)
pointsradii = [(pointsdirections[0][0],0)]
for p0,p2 in zip(pointsdirections, pointsdirections[1:]):
if len(p0)==3:
r = p0[2]
@uwezi
uwezi / 20251015_linethroughpoints.py
Last active October 15, 2025 18:10
[Line through points] Creates a line through several points. #manim #line #rounded #tip #radius
class LineThroughPoints(Line):
def __init__(self, pointsdirections, radius=0, **kwargs):
super().__init__(**kwargs)
self.pointsdirections = pointsdirections
self.radius = radius
self.set_points([pointsdirections[0][0]])
for p0,p1 in zip(pointsdirections,pointsdirections[1:]):
dx,dy,dz = p1[0]-p0[0]
if len(p0) == 3:
r = p0[2]
@uwezi
uwezi / 20250606_npn.svg
Last active September 16, 2025 07:33
[NPN transistor] Current flows in a common-emitter NPN transistor. #manim #animation #physics #electronics
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@uwezi
uwezi / 20250909_particles.py
Last active September 10, 2025 11:13
[particles in a box] Animation of particles inside a polygon with additional polygons on the inside. #manim #physics #dt #updater #intersection #collision
# https://discord.com/channels/581738731934056449/1414961601127383170/1415086069568766024
from manim import *
class dotinbox(Scene):
def construct(self):
outerbox = RegularPolygon(n=6).rotate(5*DEGREES).scale_to_fit_height(7)
innerobjs = VGroup(
RegularPolygon(n=5, fill_opacity=1).scale_to_fit_height(2).shift(UR),
Square(side_length=1).shift(DL)
)
@uwezi
uwezi / 20250823_fourier.py
Last active August 23, 2025 17:34
[Fourier epicycles] Drawing the outline of an SVG with epicycles. #manim #fft #svg #fourier
from manim import *
# inspired by Grant Sanderson's Fourier video
# translated to ManimCE and using numpy's FFT
class FFTCirclesDotScene(MovingCameraScene):
center_point = ORIGIN
slow_factor = 0.1
def get_fft_coefficients_of_path(self, path, n_samples=32768, n_freqs = 200):
@uwezi
uwezi / 20250823_possible.py
Last active August 23, 2025 11:35
[La Linea] Animation of a diamond breaking a sine wave. #manim #union #boolean
from manim import *
class possible2(Scene):
def construct(self):
phase = ValueTracker(0)
def bottom():
return VMobject().add_points_as_corners(
[
*[[x,0.5*np.sin(x-phase.get_value()),0] for x in np.linspace(-8,8,1000)],
[8,-8,0],[-8,-8,0],[-8,0,0]
]
@uwezi
uwezi / 20231202_feynman.py
Last active August 17, 2025 11:43
[Feynman diagrams] Using LaTeX to create Feynman diagrams in Manim. #manim #feynman #physics
from manim import *
# https://discord.com/channels/581738731934056449/1178561529914871818/1180619063161016390
class feynman(Scene):
def construct(self):
MyTexTemplate = TexTemplate()
MyTexTemplate.add_to_preamble(r"\usepackage{tikz}\usepackage[compat=1.1.0]{tikz-feynman}")
feyn = Tex(r"""
\begin{tikzpicture}
@uwezi
uwezi / 20250715_pango.py
Created July 15, 2025 07:37
[test fonts] Test pango fonts for compatibility with non-latin scripts. #manim #pango #text #fontlist #font
from manim import *
class testarabic(Scene):
def construct(self):
i=0
texts = VGroup()
for font in Text.font_list():
print(font)
texts += VGroup(
Text(font, font_size=18).next_to([0,3.5-0.8*i,0],LEFT,buff=0.5),
Text("جيب", font=font).next_to([0,3.5-0.8*i,0],RIGHT,buff=0)
@uwezi
uwezi / 20250712_cli.py
Created July 13, 2025 08:13
[command line arguments] How to use command line arguments inside a Manim scene. #manim #sys #commandline #tempconfig
from manim import *
import sys
class clitest(Scene):
def construct(self):
args = VGroup(
Text(arg)
for arg in self.argv
).arrange(DOWN)
self.add(args)