@@ -24,6 +24,7 @@ def __init__(self, l: bool, settings: List[str]):
2424 super ().__init__ ()
2525 self .l = l
2626 self .settings = settings
27+ self .time_per_char = 0.05
2728
2829 for i , setting in enumerate (self .settings ):
2930 if " " in setting :
@@ -47,12 +48,13 @@ def construct(self):
4748
4849 def add_details (self ):
4950 down_shift = m .DOWN * 0.5
50- self .camera .frame .scale_to_fit_width (18 * 1.1 )
5151 project_root = m .Rectangle (
5252 height = 9.0 ,
5353 width = 18.0 ,
5454 color = self .fontColor ,
55- )
55+ ).move_to ((0 , 1000 , 0 ))
56+ self .camera .frame .scale_to_fit_width (18 * 1.1 )
57+ self .camera .frame .move_to (project_root .get_center ())
5658
5759 cmd_text = m .Text (
5860 self .trim_cmd (self .cmd , 50 ),
@@ -87,11 +89,11 @@ def add_details(self):
8789 config_text .align_to (dot_git_text , m .UP ).shift (down_shift ).align_to (dot_git_text , m .LEFT ).shift (m .RIGHT * 0.5 )
8890
8991 if settings .animate :
90- self .play (m .AddTextLetterByLetter (cmd_text ))
91- self .play (m .Create (project_root ))
92- self .play (m .AddTextLetterByLetter (project_root_text ))
93- self .play (m .AddTextLetterByLetter (dot_git_text ))
94- self .play (m .AddTextLetterByLetter (config_text ))
92+ self .play (m .AddTextLetterByLetter (cmd_text , time_per_char = self . time_per_char ))
93+ self .play (m .Create (project_root , time_per_char = self . time_per_char ))
94+ self .play (m .AddTextLetterByLetter (project_root_text , time_per_char = self . time_per_char ))
95+ self .play (m .AddTextLetterByLetter (dot_git_text , time_per_char = self . time_per_char ))
96+ self .play (m .AddTextLetterByLetter (config_text , time_per_char = self . time_per_char ))
9597 else :
9698 self .add (cmd_text )
9799 self .add (project_root )
@@ -102,23 +104,26 @@ def add_details(self):
102104 config = self .repo .config_reader ()
103105 if self .l :
104106 last_element = config_text
105- for section in config .sections ():
107+ for i , section in enumerate ( config .sections () ):
106108 section_text = m .Text (f"[{ section } ]" , font = self .font , color = self .fontColor , font_size = 20 ).align_to (last_element , m .UP ).shift (down_shift ).align_to (config_text , m .LEFT ).shift (m .RIGHT * 0.5 )
107109 self .toFadeOut .add (section_text )
108110 if settings .animate :
109- self .play (m .AddTextLetterByLetter (section_text ))
111+ self .play (m .AddTextLetterByLetter (section_text , time_per_char = self . time_per_char ))
110112 else :
111113 self .add (section_text )
112114 last_element = section_text
113- for option in config .options (section ):
115+ project_root = self .resize_rectangle (project_root , last_element )
116+ for j , option in enumerate (config .options (section )):
114117 if option != "__name__" :
115118 option_text = m .Text (f"{ option } = { config .get_value (section , option )} " , font = self .font , color = self .fontColor , font_size = 20 ).align_to (last_element , m .UP ).shift (down_shift ).align_to (section_text , m .LEFT ).shift (m .RIGHT * 0.5 )
116119 self .toFadeOut .add (option_text )
117120 last_element = option_text
118121 if settings .animate :
119- self .play (m .AddTextLetterByLetter (option_text ))
122+ self .play (m .AddTextLetterByLetter (option_text , time_per_char = self . time_per_char ))
120123 else :
121124 self .add (option_text )
125+ if not (i == len (config .sections ()) - 1 and j == len (config .options (section )) - 1 ):
126+ project_root = self .resize_rectangle (project_root , last_element )
122127 else :
123128 if not self .settings :
124129 print ("git-sim error: no config option specified" )
@@ -140,13 +145,12 @@ def add_details(self):
140145 elif len (self .settings ) == 2 :
141146 value = self .settings [1 ].strip ('"' ).strip ("'" ).strip ("\\ " )
142147 section_text = m .Text (f"[{ self .trim_cmd (section , 50 )} ]" , font = self .font , color = self .fontColor , font_size = 20 , weight = m .BOLD ).align_to (config_text , m .UP ).shift (down_shift ).align_to (config_text , m .LEFT ).shift (m .RIGHT * 0.5 )
143-
144148 option_text = m .Text (f"{ self .trim_cmd (option , 40 )} = { self .trim_cmd (value , 40 )} " , font = self .font , color = self .fontColor , font_size = 20 , weight = m .BOLD ).align_to (section_text , m .UP ).shift (down_shift ).align_to (section_text , m .LEFT ).shift (m .RIGHT * 0.5 )
145149 self .toFadeOut .add (section_text )
146150 self .toFadeOut .add (option_text )
147151 if settings .animate :
148- self .play (m .AddTextLetterByLetter (section_text ))
149- self .play (m .AddTextLetterByLetter (option_text ))
152+ self .play (m .AddTextLetterByLetter (section_text , time_per_char = self . time_per_char ))
153+ self .play (m .AddTextLetterByLetter (option_text , time_per_char = self . time_per_char ))
150154 else :
151155 self .add (section_text )
152156 self .add (option_text )
@@ -156,3 +160,19 @@ def add_details(self):
156160 self .toFadeOut .add (project_root_text )
157161 self .toFadeOut .add (dot_git_text )
158162 self .toFadeOut .add (config_text )
163+
164+ def resize_rectangle (self , rect , last_element ):
165+ if last_element .get_bottom ()[1 ] - 3 * last_element .height > rect .get_bottom ()[1 ]:
166+ return rect
167+ new_rect = m .Rectangle (width = rect .width , height = rect .height + 2 * last_element .height , color = rect .color )
168+ new_rect .align_to (rect , m .UP )
169+ self .toFadeOut .remove (rect )
170+ self .toFadeOut .add (new_rect )
171+ if settings .animate :
172+ self .recenter_frame ()
173+ self .scale_frame ()
174+ self .play (m .ReplacementTransform (rect , new_rect ))
175+ else :
176+ self .remove (rect )
177+ self .add (new_rect )
178+ return new_rect
0 commit comments