Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20220919_multTable.py
Created March 19, 2023 12:45
[Multiplication table] Create a multiplication table in a loop. #manim #loop #latex #mathtable
from manim import *
class multiplication(Scene):
def construct(self):
for a in [1,2,3]:
theTable = []
for b in range(10):
theTable.append([a, r"\times", b+1, r"=", a*(b+1)])
texTable = MathTable(theTable,include_outer_lines=False).scale(0.6).to_edge(UP)
texTable.remove(*texTable.get_vertical_lines())
@uwezi
uwezi / 20220920_squaresum.py
Created March 19, 2023 12:52
[Mobject grouping] Grouping squares inside a loop. #manim #square #loop #animate #vgroup
# https://discord.com/channels/581738731934056449/1021822343120687135/1021843567905353788
from manim import *
class test17(Scene):
def construct(self):
baselen = 0.5
max_n = 10
origo = 3*LEFT+3*DOWN
sq = Square(side_length=baselen)
@uwezi
uwezi / 20220927_clockface.py
Last active March 19, 2023 13:43
[Custom labels on a PolarPlane] Putting your own labels onto a PolarPlane. #manim #polarplane #labels
# https://discord.com/channels/581738731934056449/1023856228377563227/1024233361130135552
from manim import *
class ClockFaces(Scene):
def draw_text_lines(self, line1, line2, offset=np.array([3.5, 0.5, 0])):
text_heading = Text(line1)
text_heading.shift(offset)
text_body = Text(line2)
text_body.next_to(text_heading, DOWN)
@uwezi
uwezi / 20220922_stix2.py
Last active March 19, 2023 13:08
[STIX2 LaTeX font in Manim] How to use the stix2-fontpackage in Manim's LaTeX. #manim #latex #xetex #stix2 #font
# https://discord.com/channels/581738731934056449/1021149218523586560/1022599268051202078
from manim import *
myTexTemp2 = TexTemplate(
tex_compiler="xelatex",
output_format='.pdf',
)
myTexTemp2.add_to_preamble(r"\usepackage{siunitx}")
myTexTemp4 = TexTemplate(
@uwezi
uwezi / 20221001_barchart.py
Last active March 19, 2023 13:16
[Barchart with labels] How to plot a barchart with own labels - porting code from 3B1B. #manim #barchart #labels
# https://discord.com/channels/581738731934056449/1025728276343296031/1025765609667047454
from manim import *
class myAnimation(Scene):
CONFIG = {
"x_length": 10,
"y_length": 4,
#"n_ticks": 4,
#"tick_width": 0.2,
@uwezi
uwezi / 20221001_applymatrix.py
Last active March 19, 2023 13:19
[Apply matrix to objects] Deforming the number plane and objects using a matrix. #manim #applymatrix #linalg #animate
# https://discord.com/channels/581738731934056449/1025492231035039764/1025695274817028096
from manim import *
class ApplyMatrixExample(Scene):
def construct(self):
m1 = [[1, 1], [0, 2/3]]
m2 = [[0, -2], [-1, -2/3]]
np = NumberPlane()
txt = Text("Hello World!")
@uwezi
uwezi / 20220924_minipage.py
Last active March 19, 2023 13:23
[formatted text blocks in Manim] How to use the minipage environment for better typesetting. #manim #latex #minipage
# https://discord.com/channels/581738731934056449/1022676024238026774/1022997149656567888
from manim import *
class test15(Scene):
def construct(self):
text = r'''{5cm}Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Nulla et velit a
mauris pharetra efficitur. Pellentesque quis diam
at justo venenatis lacinia non posuere orci. Nulla
@uwezi
uwezi / 20221002_mathtable.py
Last active March 19, 2023 13:29
[animate a MathTable] Choose what to draw first and modify elements in a MathTable. #manim "mathtable #animate
# https://discord.com/channels/581738731934056449/1026084532207755295/1026136828954300426
from manim import *
class Tabla2(Scene):
def construct(self):
t=MathTable(
[["", 2,3,4],
[2,3,4,5],
[2, 2, 7, 12],
@uwezi
uwezi / 20221002_latexpointer.py
Last active March 19, 2023 13:35
[Pointing to individual characters in a Tex-string] How to draw an arrow pointing to individual characters in a LaTeX object. #manim #latex #animate
# https://discord.com/channels/581738731934056449/1026231302069964831/1026240005401751582
from manim import *
class moving(Scene):
def construct(self):
text = Tex(r"And ",r"still ",r"it ", r"moves!")
self.play(Write(text))
arr = Arrow(start=ORIGIN, end=1*UP, buff=0).next_to(text[0],DOWN,buff=0)
self.play(Create(arr))
@uwezi
uwezi / 29221993_tree.py
Last active March 19, 2023 13:43
[L-system tree] How to build an L-system tree in Manim. #manim #lsystem #dataclasses #artist #tree #animate
# code by @Maieutic
# https://discord.com/channels/581738731934056449/1026221281810579556/1026253177177255957
from dataclasses import dataclass
from manim import *
import numpy as np
L_SYSTEM = {
"axiom": "F",
"rules": {"F": "F[-F][+F]", "+": "+", "-": "-", "[": "[", "]": "]"},