Skip to content

Extract function exclude_dots_from_mobject in text_mobject.py #4394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions manim/mobject/text/text_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,23 @@ def remove_invisible_chars(mobject: SVGMobject) -> SVGMobject:
:class:`~.SVGMobject`
The SVGMobject without unwanted invisible characters.
"""
# TODO: Refactor needed
iscode = False
if mobject.__class__.__name__ == "Text":
mobject = mobject[:]
return exclude_dots_from_mobject(mobject[:])
elif mobject.__class__.__name__ == "Code":
iscode = True
code = mobject
mobject = mobject.code
mobject.code = exclude_dots_from_mobject(mobject.code)
return mobject
else:
return exclude_dots_from_mobject(mobject)


def exclude_dots_from_mobject(mobject: SVGMobject) -> SVGMobject:
mobject_without_dots = VGroup()
if mobject[0].__class__ == VGroup:
for i in range(len(mobject)):
mobject_without_dots.add(VGroup())
mobject_without_dots[i].add(*(k for k in mobject[i] if k.__class__ != Dot))
else:
mobject_without_dots.add(*(k for k in mobject if k.__class__ != Dot))
if iscode:
code.code = mobject_without_dots
return code
return mobject_without_dots


Expand Down
Loading