Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active October 7, 2023 08:18
Show Gist options
  • Save uwezi/faf5690066b475c4e8145b6e48a00f60 to your computer and use it in GitHub Desktop.
Save uwezi/faf5690066b475c4e8145b6e48a00f60 to your computer and use it in GitHub Desktop.
[Tikz state diagram] Another, cleaner state diagram in Tikz. #manim #latex #tikz
class automaton(Scene):
def construct(self):
template = TexTemplate()
template.add_to_preamble(r"\usepackage{tikz}")
template.add_to_preamble(r"\usetikzlibrary{arrows}")
tex = Tex(
r"""[->,>=stealth',node distance=3cm]
\node[circle,draw] (1) {A};
\node[circle,draw] (2) [right of=1] {B};
\path[] (2) edge[out=150,in=30] (1);
\path[] (1) edge[out=-30,in=210] (2);
\path[] (1) edge[loop above,min distance=10mm,out=70,in=110,looseness=10] (1);
\path[] (2) edge[loop below] (2);
""",
tex_template=template,
tex_environment="tikzpicture",
fill_opacity=0,
stroke_width=2,
stroke_opacity=1,
font_size=30,
)
self.play(Create(tex), run_time = 5)
self.wait()
self.add(index_labels(tex[0]).set_color(RED))
self.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment