1- from manim import *
1+ import sys
2+
3+ import git
4+ import manim as m
5+ import numpy
6+
27from git_sim .git_sim_base_command import GitSimBaseCommand
3- import git , sys , numpy
8+
49
510class 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 )
0 commit comments