sreepathi-ravikumar commited on
Commit
d306fc1
·
verified ·
1 Parent(s): b165e2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -73,7 +73,7 @@ def create_manim_script(problem_data, script_path):
73
  "highlight_color": "YELLOW",
74
  "font": "",
75
  "text_size": 36,
76
- "equation_size": 42,
77
  "title_size": 48,
78
  "wrap_width": 18.0 # in scene width units; adjust to taste
79
  })
@@ -85,7 +85,7 @@ def create_manim_script(problem_data, script_path):
85
  slides_repr = repr(slides)
86
 
87
  # Use a dedicated wrap width in scene units; you can adapt how max_width is computed
88
- wrap_width = float(settings.get("wrap_width", 12.0))
89
 
90
  manim_code = f'''
91
  from manim import *
@@ -98,7 +98,7 @@ class GeneratedMathScene(Scene):
98
  highlight_color = {settings.get('highlight_color', 'YELLOW')}
99
  default_font = "{settings.get('font', 'CMU Serif')}"
100
  text_size = {settings.get('text_size', 36)}
101
- equation_size = {settings.get('equation_size', 42)}
102
  title_size = {settings.get('title_size', 48)}
103
  wrap_width = {wrap_width}
104
 
@@ -107,19 +107,30 @@ class GeneratedMathScene(Scene):
107
  lines = []
108
  words = content.split()
109
  current = ""
 
110
  for w in words:
111
  test = w if not current else current + " " + w
112
  test_obj = Text(test, color=color, font=font, font_size=font_size)
113
- if test_obj.width <= wrap_width * 0.9: # a bit of padding
 
114
  current = test
115
  else:
116
- lines.append(Text(current, color=color, font=font, font_size=font_size))
 
117
  current = w
 
118
  if current:
119
  lines.append(Text(current, color=color, font=font, font_size=font_size))
 
120
  if not lines:
121
  return VGroup()
122
- para = VGroup(*lines).arrange(DOWN, buff=line_spacing)
 
 
 
 
 
 
123
  return para
124
  class GeneratedMathSceneInner(Scene):
125
  pass
 
73
  "highlight_color": "YELLOW",
74
  "font": "",
75
  "text_size": 36,
76
+ "equation_size": 45,
77
  "title_size": 48,
78
  "wrap_width": 18.0 # in scene width units; adjust to taste
79
  })
 
85
  slides_repr = repr(slides)
86
 
87
  # Use a dedicated wrap width in scene units; you can adapt how max_width is computed
88
+ wrap_width = float(settings.get("wrap_width", 18.0))
89
 
90
  manim_code = f'''
91
  from manim import *
 
98
  highlight_color = {settings.get('highlight_color', 'YELLOW')}
99
  default_font = "{settings.get('font', 'CMU Serif')}"
100
  text_size = {settings.get('text_size', 36)}
101
+ equation_size = {settings.get('equation_size', 45)}
102
  title_size = {settings.get('title_size', 48)}
103
  wrap_width = {wrap_width}
104
 
 
107
  lines = []
108
  words = content.split()
109
  current = ""
110
+
111
  for w in words:
112
  test = w if not current else current + " " + w
113
  test_obj = Text(test, color=color, font=font, font_size=font_size)
114
+
115
+ if test_obj.width <= wrap_width * 0.9:
116
  current = test
117
  else:
118
+ line_obj = Text(current, color=color, font=font, font_size=font_size)
119
+ lines.append(line_obj)
120
  current = w
121
+
122
  if current:
123
  lines.append(Text(current, color=color, font=font, font_size=font_size))
124
+
125
  if not lines:
126
  return VGroup()
127
+
128
+ # --- FIX: Force every line to align to LEFT like line 1 ---
129
+ first_line = lines[0]
130
+ for ln in lines:
131
+ ln.align_to(first_line, LEFT)
132
+
133
+ para = VGroup(*lines).arrange(DOWN, aligned_edge=LEFT, buff=line_spacing)
134
  return para
135
  class GeneratedMathSceneInner(Scene):
136
  pass