Skip to content

Commit 9d2e162

Browse files
committed
import manim as m
1 parent fdf775b commit 9d2e162

15 files changed

+240
-172
lines changed

git_sim/git_sim.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from manim import BLACK, WHITE, MovingCameraScene
1+
import manim as m
22

33
from git_sim.git_sim_add import GitSimAdd
44
from git_sim.git_sim_branch import GitSimBranch
@@ -15,15 +15,15 @@
1515
from git_sim.git_sim_tag import GitSimTag
1616

1717

18-
class GitSim(MovingCameraScene):
18+
class GitSim(m.MovingCameraScene):
1919
def __init__(self, args):
2020
super().__init__()
2121
self.args = args
2222

2323
if ( self.args.light_mode ):
24-
self.fontColor = BLACK
24+
self.fontColor = m.BLACK
2525
else:
26-
self.fontColor = WHITE
26+
self.fontColor = m.WHITE
2727

2828
def construct(self):
2929
if self.args.subcommand == 'log':

git_sim/git_sim_add.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
from manim import *
1+
import sys
2+
3+
import manim as m
4+
25
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
6+
47

58
class GitSimAdd(GitSimBaseCommand):
69
def __init__(self, scene):
@@ -56,4 +59,4 @@ def populate_zones(self, firstColumnFileNames, secondColumnFileNames, thirdColum
5659
for name in self.scene.args.name:
5760
if name == z:
5861
thirdColumnFileNames.add(z)
59-
firstColumnArrowMap[z] = Arrow(stroke_width=3, color=self.scene.fontColor)
62+
firstColumnArrowMap[z] = m.Arrow(stroke_width=3, color=self.scene.fontColor)

git_sim/git_sim_base_command.py

Lines changed: 100 additions & 95 deletions
Large diffs are not rendered by default.

git_sim/git_sim_branch.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from manim import *
1+
import sys
2+
3+
import git
4+
import manim as m
5+
import numpy
6+
27
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
8+
49

510
class GitSimBranch(GitSimBaseCommand):
611
def __init__(self, scene):
@@ -15,16 +20,16 @@ def execute(self):
1520
self.recenter_frame()
1621
self.scale_frame()
1722

18-
branchText = Text(self.scene.args.name, font="Monospace", font_size=20, color=self.scene.fontColor)
19-
branchRec = Rectangle(color=GREEN, fill_color=GREEN, fill_opacity=0.25, height=0.4, width=branchText.width+0.25)
23+
branchText = m.Text(self.scene.args.name, font="Monospace", font_size=20, color=self.scene.fontColor)
24+
branchRec = m.Rectangle(color=m.GREEN, fill_color=m.GREEN, fill_opacity=0.25, height=0.4, width=branchText.width+0.25)
2025

21-
branchRec.next_to(self.topref, UP)
26+
branchRec.next_to(self.topref, m.UP)
2227
branchText.move_to(branchRec.get_center())
2328

24-
fullbranch = VGroup(branchRec, branchText)
29+
fullbranch = m.VGroup(branchRec, branchText)
2530

2631
if self.scene.args.animate:
27-
self.scene.play(Create(fullbranch), run_time=1/self.scene.args.speed)
32+
self.scene.play(m.Create(fullbranch), run_time=1/self.scene.args.speed)
2833
else:
2934
self.scene.add(fullbranch)
3035

git_sim/git_sim_cherrypick.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from manim import *
1+
import sys
2+
3+
import git
4+
import manim as m
5+
import numpy
6+
27
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
8+
49

510
class GitSimCherryPick(GitSimBaseCommand):
611
def __init__(self, scene):
@@ -32,7 +37,7 @@ def execute(self):
3237
self.parse_commits(self.commits[0])
3338
self.orig_commits = self.commits
3439
self.get_commits(start=self.scene.args.commit[0])
35-
self.parse_commits(self.commits[0], shift=4*DOWN)
40+
self.parse_commits(self.commits[0], shift=4*m.DOWN)
3641
self.center_frame_on_commit(self.orig_commits[0])
3742
self.setup_and_draw_parent(self.orig_commits[0], self.commits[0].message)
3843
self.draw_arrow_between_commits(self.commits[0].hexsha, "abcdef")

git_sim/git_sim_commit.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from manim import *
1+
import sys
2+
3+
import git
4+
import manim as m
5+
import numpy
6+
27
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
8+
49

510
class GitSimCommit(GitSimBaseCommand):
611
def __init__(self, scene):
@@ -41,4 +46,4 @@ def populate_zones(self, firstColumnFileNames, secondColumnFileNames, thirdColum
4146
if "git-sim_media" not in y.a_path:
4247
secondColumnFileNames.add(y.a_path)
4348
thirdColumnFileNames.add(y.a_path)
44-
secondColumnArrowMap[y.a_path] = Arrow(stroke_width=3, color=self.scene.fontColor)
49+
secondColumnArrowMap[y.a_path] = m.Arrow(stroke_width=3, color=self.scene.fontColor)

git_sim/git_sim_log.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from manim import *
1+
import sys
2+
3+
import git
4+
import manim as m
5+
import numpy
6+
27
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
8+
49

510
class GitSimLog(GitSimBaseCommand):
611
def __init__(self, scene):

git_sim/git_sim_merge.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from manim import *
1+
import sys
2+
3+
import git
4+
import manim as m
5+
import numpy
6+
27
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
8+
49

510
class GitSimMerge(GitSimBaseCommand):
611
def __init__(self, scene):
@@ -55,15 +60,15 @@ def execute(self):
5560
self.reset_head_branch(reset_head_to, shift=shift)
5661
else:
5762
self.draw_ref(self.commits[0], commitId if self.scene.args.no_ff else self.topref)
58-
self.draw_ref(self.commits[0], self.drawnRefs["HEAD"] if self.scene.args.no_ff else self.topref, text=self.repo.active_branch.name, color=GREEN)
63+
self.draw_ref(self.commits[0], self.drawnRefs["HEAD"] if self.scene.args.no_ff else self.topref, text=self.repo.active_branch.name, color=m.GREEN)
5964

6065
else:
6166
self.get_commits()
6267
self.parse_commits(self.commits[0])
6368
self.get_commits(start=self.scene.args.branch[0])
64-
self.parse_commits(self.commits[0], shift=4*DOWN)
69+
self.parse_commits(self.commits[0], shift=4*m.DOWN)
6570
self.center_frame_on_commit(self.orig_commits[0])
66-
self.setup_and_draw_parent(self.orig_commits[0], "Merge commit", shift=2*DOWN, draw_arrow=False, color=GRAY)
71+
self.setup_and_draw_parent(self.orig_commits[0], "Merge commit", shift=2*m.DOWN, draw_arrow=False, color=m.GRAY)
6772
self.draw_arrow_between_commits("abcdef", self.commits[0].hexsha)
6873
self.draw_arrow_between_commits("abcdef", self.orig_commits[0].hexsha)
6974
self.recenter_frame()

git_sim/git_sim_rebase.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from manim import *
1+
import sys
2+
3+
import git
4+
import manim as m
5+
import numpy
6+
27
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
8+
49

510
class GitSimRebase(GitSimBaseCommand):
611
def __init__(self, scene):
@@ -36,13 +41,13 @@ def execute(self):
3641
self.parse_commits(self.commits[0])
3742
self.orig_commits = self.commits
3843
self.get_commits()
39-
self.parse_commits(self.commits[0], shift=4*DOWN)
44+
self.parse_commits(self.commits[0], shift=4*m.DOWN)
4045
self.center_frame_on_commit(self.orig_commits[0])
4146

4247
to_rebase = []
4348
i = 0
4449
current = self.commits[i]
45-
while self.scene.args.branch[0] not in self.repo.git.branch("--contains", current):
50+
while self.scene.args.branch[0] not in self.repo.git.branch("--contains", current):
4651
to_rebase.append(current)
4752
i += 1
4853
current = self.commits[i]
@@ -51,34 +56,34 @@ def execute(self):
5156
for tr in reversed(to_rebase):
5257
parent = self.setup_and_draw_parent(parent, tr.message)
5358
self.draw_arrow_between_commits(tr.hexsha, parent)
54-
59+
5560
self.recenter_frame()
5661
self.scale_frame()
5762
self.reset_head_branch(parent)
5863
self.fadeout()
5964
self.show_outro()
6065

6166
def setup_and_draw_parent(self, child, commitMessage="New commit", shift=numpy.array([0., 0., 0.]), draw_arrow=True):
62-
circle = Circle(stroke_color=RED, fill_color=RED, fill_opacity=0.25)
63-
circle.height = 1
64-
circle.next_to(self.drawnCommits[child], LEFT if self.scene.args.reverse else RIGHT, buff=1.5)
67+
circle = m.Circle(stroke_color=m.RED, fill_color=m.RED, fill_opacity=0.25)
68+
circle.height = 1
69+
circle.next_to(self.drawnCommits[child], m.LEFT if self.scene.args.reverse else m.RIGHT, buff=1.5)
6570
circle.shift(shift)
6671

6772
start = circle.get_center()
6873
end = self.drawnCommits[child].get_center()
69-
arrow = Arrow(start, end, color=self.scene.fontColor)
74+
arrow = m.Arrow(start, end, color=self.scene.fontColor)
7075
length = numpy.linalg.norm(start-end) - ( 1.5 if start[1] == end[1] else 3 )
7176
arrow.set_length(length)
7277
sha = "".join(chr(ord(letter)+1) if (chr(ord(letter)+1).isalpha() or chr(ord(letter)+1).isdigit()) else letter for letter in child[:6])
73-
commitId = Text(sha, font="Monospace", font_size=20, color=self.scene.fontColor).next_to(circle, UP)
78+
commitId = m.Text(sha, font="Monospace", font_size=20, color=self.scene.fontColor).next_to(circle, m.UP)
7479
self.toFadeOut.add(commitId)
7580

7681
commitMessage = commitMessage[:40].replace("\n", " ")
77-
message = Text('\n'.join(commitMessage[j:j+20] for j in range(0, len(commitMessage), 20))[:100], font="Monospace", font_size=14, color=self.scene.fontColor).next_to(circle, DOWN)
82+
message = m.Text('\n'.join(commitMessage[j:j+20] for j in range(0, len(commitMessage), 20))[:100], font="Monospace", font_size=14, color=self.scene.fontColor).next_to(circle, m.DOWN)
7883
self.toFadeOut.add(message)
7984

8085
if self.scene.args.animate:
81-
self.scene.play(self.scene.camera.frame.animate.move_to(circle.get_center()), Create(circle), AddTextLetterByLetter(commitId), AddTextLetterByLetter(message), run_time=1/self.scene.args.speed)
86+
self.scene.play(self.scene.camera.frame.animate.move_to(circle.get_center()), m.Create(circle), m.AddTextLetterByLetter(commitId), m.AddTextLetterByLetter(message), run_time=1/self.scene.args.speed)
8287
else:
8388
self.scene.camera.frame.move_to(circle.get_center())
8489
self.scene.add(circle, commitId, message)
@@ -88,7 +93,7 @@ def setup_and_draw_parent(self, child, commitMessage="New commit", shift=numpy.a
8893

8994
if draw_arrow:
9095
if self.scene.args.animate:
91-
self.scene.play(Create(arrow), run_time=1/self.scene.args.speed)
96+
self.scene.play(m.Create(arrow), run_time=1/self.scene.args.speed)
9297
else:
9398
self.scene.add(arrow)
9499
self.toFadeOut.add(arrow)

git_sim/git_sim_reset.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from manim import *
1+
import sys
2+
3+
import git
4+
import manim as m
5+
import numpy
6+
27
from git_sim.git_sim_base_command import GitSimBaseCommand
3-
import git, sys, numpy
8+
49

510
class GitSimReset(GitSimBaseCommand):
611
def __init__(self, scene):
@@ -45,19 +50,19 @@ def execute(self):
4550
def build_commit_id_and_message(self, commit):
4651
hide_refs = False
4752
if commit == "dark":
48-
commitId = Text('', font="Monospace", font_size=20, color=self.scene.fontColor)
53+
commitId = m.Text('', font="Monospace", font_size=20, color=self.scene.fontColor)
4954
commitMessage = ''
5055
elif self.i == 3 and self.resetTo.hexsha not in [commit.hexsha for commit in self.get_nondark_commits()]:
51-
commitId = Text('...', font="Monospace", font_size=20, color=self.scene.fontColor)
56+
commitId = m.Text('...', font="Monospace", font_size=20, color=self.scene.fontColor)
5257
commitMessage = '...'
5358
hide_refs = True
5459
elif self.i == 4 and self.resetTo.hexsha not in [commit.hexsha for commit in self.get_nondark_commits()]:
55-
commitId = Text(self.resetTo.hexsha[:6], font="Monospace", font_size=20, color=self.scene.fontColor)
60+
commitId = m.Text(self.resetTo.hexsha[:6], font="Monospace", font_size=20, color=self.scene.fontColor)
5661
commitMessage = self.resetTo.message.split("\n")[0][:40].replace("\n", " ")
5762
commit = self.resetTo
5863
hide_refs = True
5964
else:
60-
commitId = Text(commit.hexsha[:6], font="Monospace", font_size=20, color=self.scene.fontColor)
65+
commitId = m.Text(commit.hexsha[:6], font="Monospace", font_size=20, color=self.scene.fontColor)
6166
commitMessage = commit.message.split("\n")[0][:40].replace("\n", " ")
6267

6368
if commit != "dark" and commit.hexsha == self.resetTo.hexsha and commit.hexsha != self.repo.head.commit.hexsha:

0 commit comments

Comments
 (0)