Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20230319_zigzag.py
Last active April 15, 2023 21:33
[Create a zig-zag line] Inline code to create a zig-zag line using a VMobject #manim #line #zigzag #vmobject
# https://discord.com/channels/581738731934056449/1086715297928581161/1086715297928581161
from manim import *
class zig(Scene):
def construct(self):
zag = VMobject()
n=4
zag.set_points_as_corners(
[[PI/2*i,np.sin(PI/2*i),0] for i in range(4*n+1)]
).scale_to_fit_width(5).move_to([-3,0,0],aligned_edge=LEFT)
self.add(zag)
@uwezi
uwezi / 20230211_hindi.py
Last active March 21, 2023 23:13
[Hindi language using LaTeX in Manim] How to create text in the Hindi language in Manim #manim #latex #fontspec #xetex #font
# https://discord.com/channels/581738731934056449/1074019689073741935/1074019689073741935
from manim import *
myTexTemplate = TexTemplate(
tex_compiler="xelatex",
output_format='.xdv',
)
myTexTemplate.add_to_preamble(r"\usepackage{fontspec}\setmainfont{Akshar Unicode.ttf}")
MathTex.set_default(tex_template=myTexTemplate)
Tex.set_default(tex_template=myTexTemplate)
@uwezi
uwezi / 20230319_hilbert.py
Created March 19, 2023 11:36
[Hilbert curve] How to draw a Hilbert curve in Manim #manim #vmobject #math #hilbert
# original code @vasek.rozhon, modified by @uwezi
#https://discord.com/channels/581738731934056449/1086715297928581161/1086722509417762836
from manim import *
class Hilbert(Scene):
def construct(self):
from hilbertcurve.hilbertcurve import HilbertCurve
side_length = 4
@uwezi
uwezi / 20230111_circuitikz.py
Created March 19, 2023 11:47
[Circuitikz in Manim] How to use circuitikz in Manim #latex #tikz #manim #electronics #circuitikz
# https://discord.com/channels/581738731934056449/1048986980769333329/1062860351567319062
# https://discord.com/channels/581738731934056449/1062828056235999242/1062836565983903835
# import from KiCAD and LTspice: https://github.com/uwezi/circuitikz_import
from manim import *
class circuit(Scene):
def construct(self):
template = TexTemplate()
template.add_to_preamble(r"\usepackage{tikz}\usepackage[europeanresistors,americaninductors]{circuitikz}")
@uwezi
uwezi / 20220916_angle.py
Last active March 19, 2023 12:04
[display angle value animated] How to display the value of an angle not using updaters #manim #angle #decimalnumber #loop #noupdater #animate
# https://discord.com/channels/581738731934056449/1020039781276721234/1020193585305505882
from manim import *
class smoother(Scene):
def construct(self):
line1 = Line(ORIGIN, RIGHT+(1/3)*DOWN)
line2 = Line(ORIGIN, UP+(1/3)*LEFT)
angle = Angle(line1, line2, radius=0.4)
@uwezi
uwezi / 20220916_ratefuncs.py
Created March 19, 2023 11:53
[different rate functions] How to use different rate functions in the same animation #manim #updater #valuetracker #rate_functions
# @Benjamin Hackl and @kolibril13
# https://discord.com/channels/581738731934056449/1020428420498333696/1020431068236628001
from manim import *
class MeineSzene(Scene):
def construct(self):
line1 = Line(3*LEFT, 3*RIGHT).shift(UP).set_color(RED)
line2 = Line(3*LEFT, 3*RIGHT).set_color(GREEN)
d1 = Dot().move_to(line1.get_left())
@uwezi
uwezi / 20220917_trace.py
Last active March 19, 2023 12:38
[leaving a trace in Manim] How to leave a trace of objects by making copies. #manim #copy #trace #shift
# https://discord.com/channels/581738731934056449/1020700254061989939/1020700254061989939
from manim import *
class tracesquare(MovingCameraScene):
def construct(self):
grid = NumberPlane()
self.add(grid)
s = Square(side_length=2, color=RED, fill_opacity=0.2)
self.add(grid, s)
@uwezi
uwezi / 20220918_linestopoint.py
Last active March 19, 2023 12:41
[x/y lines to point on curve animated] How to animate .get_lines_to_point() #manim #valuetracker #animate #plot #get_lines_to_point
# https://discord.com/channels/581738731934056449/1020966805923188736/1020992408529416254
from manim import *
class axes(Scene):
def construct(self):
plane = NumberPlane(background_line_style={"stroke_opacity": 0.5})
self.play(Create(plane))
def f(x):
return x**2
@uwezi
uwezi / 20220919_zindex.py
Last active March 19, 2023 12:40
[stacking objects] How to stack 2D-objects using z_index #manim #z_index #flash #animate
# https://discord.com/channels/581738731934056449/1021452642196668446/1021452642196668446
from manim import *
class MobsInFront(Scene):
def construct(self):
circ = Circle(radius=1,fill_color=PINK,fill_opacity=1,
stroke_color=PINK,stroke_opacity=1).set_z_index(2)
edge = Dot(circ.get_right())
anim = Flash(edge,color=BLUE,run_time=2,line_length=1)
@uwezi
uwezi / 20220919_line2square.py
Last active March 19, 2023 12:33
[Fold line to square] How to make a square from a single line. #manim #fold #animate
# https://discord.com/channels/581738731934056449/1021439985615913051/1021439985615913051
from manim import *
class square_from_line(Scene):
def construct(self):
line1 = Line(start=ORIGIN, end=1*RIGHT)
line2 = line1.copy().shift(1*RIGHT)
line3 = line2.copy().shift(1*RIGHT)
line4 = line3.copy().shift(1*RIGHT)