Created
March 19, 2023 11:47
-
-
Save uwezi/6f66679acec76da059ea37d1096d92d9 to your computer and use it in GitHub Desktop.
[Circuitikz in Manim] How to use circuitikz in Manim #latex #tikz #manim #electronics #circuitikz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}") | |
c = Tex( | |
r"""[american voltages, baseline=(current bounding box.center)] | |
\draw (0,0) to [R, l=$R$] (6,0) to [V, l=$E$] (6,2) to [L, l=$L$] (0,2);""", | |
tex_environment="circuitikz", | |
tex_template=template, | |
stroke_width=2, | |
fill_opacity=0, | |
stroke_opacity=1, | |
) | |
self.play(FadeIn(c, shift=UP, target_position=ORIGIN), run_time=3) | |
self.play(ApplyWave(c[0])) | |
self.wait(2) | |
class circuit2(Scene): | |
def construct(self): | |
template = TexTemplate() | |
template.add_to_preamble(r"\usepackage{tikz}\usepackage{circuitikz}") | |
c = Tex( | |
r"""[american voltages, baseline=(current bounding box.center)] | |
\draw (0,0) | |
to[V=$V{Th}$] (0,2) | |
to[R=$R_{Th}$] (2.5,2) | |
to[short,i=$I$, -o] (4,2) | |
to[short] (4.5,2) | |
(0,0) to[short, -o] (4,0) | |
to[short] (4.5,0);""", | |
tex_environment="circuitikz", | |
tex_template=template, | |
stroke_width=2, | |
fill_opacity=0, | |
stroke_opacity=1, | |
) | |
self.play(FadeIn(c, shift=UP, target_position=ORIGIN), run_time=3) | |
self.play(ApplyWave(c[0])) | |
#self.play(Indicate(c[2], color=TEAL), run_time=2) | |
#self.play(Circumscribe(c[4], fade_out=True, color=BLUE)) | |
self.wait(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment