-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Fixed Some bugs of code_mobject.py and Text_mobject.py #1071
Conversation
Good job! And I think it's better to put front space characters in the first display character's position, which makes them in the first line. This can make Transform more natural. |
i don't get you. i just make cairo to handle spaces or tabs (replaced by |
Now i get it def apply_space_chars(self):
for char_index in range(self.text.__len__()):
if self.text[char_index] == " " or self.text[char_index] == "\t" or self.text[char_index] == "\n":
space = Dot(redius=0, fill_opacity=0, stroke_opacity=0)
if char_index == 0:
#Here is the mistake i forgot to remove -1
space.move_to(self.submobjects[char_index - 1].get_center())
else:
space.move_to(self.submobjects[char_index - 1].get_center())
self.submobjects.insert(char_index, space) |
manimlib/mobject/svg/text_mobject.py
Outdated
if char_index == 0: | ||
space.move_to(self.submobjects[char_index - 1].get_center()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
focus on here.
You put all non-display characters in the position of the previous character.
But if char_index==0
, the previous character is the last display character in the entire Text.
It's better to put them in the position of the first display character instead of the last one.
Yes corrected ! |
Good Job! |
its better if we just accept that space characters are not counted and make Text() that way. |
Yes, Tranform's problems are all above the spaces. |
well i have an idea but for now i don't know to achieve that |
can you explain me |
oops, I typed two spaces between b and c, but maybe GitHub shows only one space.
|
@NavpreetDevpuri I solved Bug2. def replace_identation(self):
with open(self.file_path, 'r') as fpr:
content = fpr.read()
content = re.sub(' ' * self.tab_width, '\t', content)
with open(self.file_path, 'w') as fpw:
fpw.write(content) add this method to Code(), and use it after self.ensure_valid_file()
self.replace_identation()
self.style = self.style.lower() You can commit it to your pr. and it will be perfect. |
this will replace all spaces from file for example we have to use |
m working on it class te1(Scene):
def construct(self):
text = Text(" ab\ncd\nef", font="Consolas", size=2)
text2 = Text("ab\n cd\nef", font="Consolas", size=2)
self.add(text)
text.chars[2].set_color(YELLOW)
self.wait()
text.chars[0:4].set_color(RED)
text2.chars[0:2].set_color(GREEN)
text.set_color_by_t2c(t2c={"cd": GREEN})
self.wait()
# Wrong Transform(text.chars[0:4], text2.chars[0:2])
self.play(Transform(text.get_sub_text(0, 4), text2.get_sub_text(0, 2)))
self.wait() Transformations are smoother and we can access chars by now m working on Paragraph() and Code() |
Oh, Sorry. I didn't notice the keyword |
No problem |
But don't you think this will make Transform more complicated. |
yes, but then we just have choice that
|
# WRONG
#self.play(Transform(text.chars[0:4], text2.chars[0:2]))
self.play(Transform(remove_spaces_from_chars(text.chars[0:4]), remove_spaces_from_chars(text2.chars[0:2]))) Now look better |
I still think it is too complicated. |
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
reopened at ManimCommunity/manim#198 |
* Enabled coverage.py based code coverage * integrate codecov into ci * move to pytest-cov and include .coveragerc into pyproject.toml * update poetry * Also include coverage in CI logs * updated poetry
Fixed #1067
NOTE : SurroundingRectangle() only contains visible text.
Output

Output

Added new parameters
background_stroke_width
andbackground_stroke_color
Output

Updated Paragraph() and added new methods
set_line_to_initial_position()
andset_all_lines_to_initial_positions()
Output
