Skip to content

Commit f4f2f46

Browse files
committed
Refactor suggested by Chopan50
1 parent 5a2b338 commit f4f2f46

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

manim/mobject/text/text_mobject.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,23 @@ def remove_invisible_chars(mobject: SVGMobject) -> SVGMobject:
9494
:class:`~.SVGMobject`
9595
The SVGMobject without unwanted invisible characters.
9696
"""
97-
# TODO: Refactor needed
98-
iscode = False
9997
if mobject.__class__.__name__ == "Text":
100-
mobject = mobject[:]
98+
return exclude_dots_from_mobject(mobject[:])
10199
elif mobject.__class__.__name__ == "Code":
102-
iscode = True
103-
code = mobject
104-
mobject = mobject.code
100+
mobject.code = exclude_dots_from_mobject(mobject.code)
101+
return mobject
102+
else:
103+
return exclude_dots_from_mobject(mobject)
104+
105+
106+
def exclude_dots_from_mobject(mobject: SVGMobject) -> SVGMobject:
105107
mobject_without_dots = VGroup()
106108
if mobject[0].__class__ == VGroup:
107109
for i in range(len(mobject)):
108110
mobject_without_dots.add(VGroup())
109111
mobject_without_dots[i].add(*(k for k in mobject[i] if k.__class__ != Dot))
110112
else:
111113
mobject_without_dots.add(*(k for k in mobject if k.__class__ != Dot))
112-
if iscode:
113-
code.code = mobject_without_dots
114-
return code
115114
return mobject_without_dots
116115

117116

0 commit comments

Comments
 (0)