Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20260311_pixelate.py
Created March 11, 2026 14:47
[pixelate] Pixelate Mobjects in Manim. #manim #pil #image #pixel
from PIL.Image import Resampling
class doesthiswork2(Scene):
def construct(self):
vpixels = 40
svg = VGroup(
Circle(),
Text("Test")
)
oheight = svg.height
svg.scale_to_fit_height(8/(config.pixel_height/vpixels),scale_stroke=True)
@uwezi
uwezi / 20260218_manifold.py
Last active February 18, 2026 14:38
[Manifold3D and Manim] Using the manifold3D library within Manim. #manim #3D #manifold3D #csg
from manim import *
import manifold3d as mf3
class spherical(ThreeDScene):
def construct(self):
self.set_camera_orientation(phi=70 * DEGREES, theta=-70 * DEGREES)
sp = mf3.Manifold.sphere(radius =2, circular_segments=24)
verts = sp.to_mesh().vert_properties
manimsphere = VGroup(
@uwezi
uwezi / 20260128_meterclass.py
Created January 28, 2026 17:41
[Analog meter] A class object for analog meters. #manim #animation #electronics #class
from manim import*
class AnalogMeter(VGroup):
def __init__(self,
value = 0,
width=4,
height=3.5,
corner_radius=0.5,
outer_stroke_width=5,
outer_stroke_color=GRAY,
@uwezi
uwezi / 20260124_benzene.py
Last active January 24, 2026 13:35
[animated chemistry] Using special animations on chemical formulae. #manim #chemistry #transformbyglyphmap #chemfig #animation #tikz
from MF_Tools import TransformByGlyphMap
class benzeneAnim(Scene):
def construct(self):
mol1 = Tex(
r"\chemfig{*6(-=-=-=)}",
tex_template=myChemTemplate
).set_stroke(width=3)
mol2 = Tex(
r"\chemfig{*6(--=-(=O)-=)}",
tex_template=myChemTemplate
@uwezi
uwezi / 20260124_chemfig.py
Last active January 24, 2026 12:55
[Organic chemistry] Using LaTeX's chemfig macro in Manim. #manim #latex #tikz #chemfig #chemistry
from manim import *
from mol2chemfigPy3 import mol2chemfig
myChemTemplate = TexTemplate(
tex_compiler="latex",
output_format='.dvi',
preamble=r"""
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{chemfig}
@uwezi
uwezi / 20260121_longdiv.py
Last active January 20, 2026 23:20
[long division] Long division in Manim. #manim #math #animation
class longdiv(Scene):
def construct(self):
# https://www.calculatorsoup.com/calculators/math/longdivision.php
divisor = 123
dividend = 764556
divisor_mobj = VGroup(
*Tex(f"{divisor}")[0]
)
remainder = 0
divisor_mobj.arrange_in_grid(
@uwezi
uwezi / 20260112_smiley.py
Last active January 12, 2026 13:03
[Smileys in equations] Use smiley characters in LaTeX equations in Manim. #manim #latex #smiley #pdf
class smileyeqn(Scene):
def construct(self):
smiley = ImageMobject("bilder/slightly-smiling-face_1f642.png")
tex_templ = TexTemplate()
tex_templ.add_to_preamble(r"\DeclareMathOperator{\sinc}{sinc}")
eqn = MathTex(r"\sinc(x) = \frac{\sin(x)}{x}", tex_template=tex_templ).to_edge(UP)
self.add(eqn)
eqn2 = eqn.copy().next_to(eqn,DOWN)
smiley.scale_to_fit_width(eqn2[0][5].width*1.5)
smileys = Group(
@uwezi
uwezi / 20260110_linear.py
Last active January 10, 2026 18:15
[smooth transition] Smooth transition between two linear functions. #manim #math #line
# https://math.stackexchange.com/questions/2493537/smooth-transition-between-linear-functions
class oscdot4(Scene):
def construct(self):
def f1(x):
return 0 + 0.5*x*2*PI
def f2(x):
return f1(3) + 2.5*(x-3)*2*PI
x0 = 2
@uwezi
uwezi / 20251214_spherehole.scad
Last active January 10, 2026 12:56
[Import .stl mesh] Import an .stl file as a mesh into Manim. #manim #3D #stl #mesh
$fn=60;
difference()
{
sphere(r=1.5);
cylinder(h=4,r=1,center=true);
}
@uwezi
uwezi / 20251220_mathtex.py
Last active December 20, 2025 16:13
[big expression] Finding and manipulating parts of a large LaTeX expression in LaTeX. #manim #mathtex #latex #indexlabels
from MF_Tools import ir
class bigeqn(Scene):
def construct(self):
eqn = MathTex(
r"""1+\sum_{i=1}^{2}\left\lfloor\left(
\frac{1}{\sum\limits_{j=1}^{i}\left\lfloor\left(\cos\left(\frac{(j-1)!\,+1}{j}\pi\right)^2\right)\right\rfloor}
\right)^\frac{1}{1}\right\rfloor"""
)
# uncomment for index labels
#self.add(eqn, index_labels(eqn[0]).set_color(RED))