Skip to content

Conversation

@NavpreetDevpuri
Copy link
Contributor

@NavpreetDevpuri NavpreetDevpuri commented May 26, 2020

Fixed 3b1b/manim#1067
NOTE : SurroundingRectangle() only contains visible text.

class te(Scene):
    def construct(self):
        text1 = Text(" ab ", font="Consolas", size=2)
        rect1 = SurroundingRectangle(text1)
        text1.chars[1].set_color(GREEN)
        self.add(text1,rect1)

Output
te

class bug1(Scene):
    def construct(self):
        text1 = Text("  ab\ncd", font="Consolas", size=2)
        text2 = Text("ab\ngh", font="Consolas", size=2)
        rect1 = SurroundingRectangle(text1)
        rect2 = SurroundingRectangle(text2)
        self.play(Transform(remove_invisible_chars(text1), remove_invisible_chars(text2)), Transform(rect1, rect2))
        self.wait()

Output
bug1

Added new parameters background_stroke_width and background_stroke_color

class bug2andbug3(Scene):
    def construct(self):
        helloworldc = Code(
            "helloworldc.c",
            tab_width=4,
            background_stroke_width=1,
            background_stroke_color=WHITE,
            insert_line_no=True,
            style=Code.styles_list[4],
            background="window",
            language="cpp",
        )
        helloworldcpp = Code(
            "helloworldcpp.cpp",
            tab_width=4,
            background_stroke_width=1,
            background_stroke_color=WHITE,
            insert_line_no=True,
            style=Code.styles_list[15],
            background="window",
            language="cpp",
        )
        helloworldc.move_to(np.array([-3.6, 0, 0]))
        helloworldcpp.move_to(np.array([3.1, 0, 0]))
        self.add(helloworldc,helloworldcpp)

Output
bug2andbug3

Updated Paragraph() and added new methods set_line_to_initial_position() and set_all_lines_to_initial_positions()

class para(Scene):
    def construct(self):
        t = Paragraph('this is a awesome', 'paragraph', 'With \nNewlines', '\tWith Tabs', '  With Spaces',
                      'With Alignments',
                      'center', "left", "right")
        t.set_line_alignment("center", 7)
        t.set_line_alignment("right", 9)
        t.shift(2 * RIGHT)
        rect = SurroundingRectangle(t)
        self.add(t, rect)
        self.wait()
        self.play(t.set_all_lines_alignments, "right")
        self.play(t.set_line_to_initial_position, 4)
        self.play(t.set_all_lines_to_initial_positions)
        self.play(t.set_line_alignment, "center", 7)
        self.play(t.set_line_alignment, "right", 9)
        t.chars[0][5:7].set_color(GREEN)
        t[1][0:4].set_color(YELLOW)
        self.wait()

Output
ezgif-3-3dc23c79c5fa

Copy link
Contributor

@TonyCrane TonyCrane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I still think it is not the best solution to use .chars[i] to stand for all chars, and Text[i] stands for visible chars. This will make a big difference to people who has already used Text.
I think it’s better not to change the structure or usage of Text.
You have done a good job to fix the bad display of Transform, but create .chars which changes the basic usage of Text.

What about trying rewriting __getitem__() to make Text[i] stand for all chars instead of using .chars.

@NavpreetDevpuri
Copy link
Contributor Author

What about trying rewriting __getitem__() to make Text[i] stand for all chars instead of using .chars.

i tried but don't work afficiently

@NavpreetDevpuri
Copy link
Contributor Author

NavpreetDevpuri commented May 26, 2020

Sorry, but I still think it is not the best solution for using .chars[i] to stand for all chars, and Text[i] stands for visible chars. This will make a big difference to people who has already used Text.
I think it’s better not to change the structure or usage of Text.

25 days ago we added spaces, before that Text[i] stands for visible chars
3b1b/manim#1017

@NavpreetDevpuri
Copy link
Contributor Author

Sorry, but I still think it is not the best solution to use .chars[i] to stand for all chars, and Text[i] stands for visible chars. This will make a big difference to people who has already used Text.

How many of them already used Text ?
if they used they where unable to perform Transformation animations
and if they use they probibaly used t2c ..etc

@TonyCrane
Copy link
Contributor

TonyCrane commented May 26, 2020

25 days ago we added spaces, before that Text[i] stands for visible chars

No, before you create .chars Text[i] stands for all chars.

@NavpreetDevpuri
Copy link
Contributor Author

and if they use they probibaly used t2c ..etc

Probibaly No one is using Text[] directly
and if someone used it then he/she can easily debug it

@NavpreetDevpuri
Copy link
Contributor Author

NavpreetDevpuri commented May 26, 2020

I think it’s better not to change the structure or usage of Text.

what if all community thinks that then this manim is possibly not made You can see almost all 3b1b video's script don't work because we improved manim

@TonyCrane
Copy link
Contributor

Many people I know are using Text. And will directly use Text[i] to represent the i-th of all characters, so as to modify individual characters. This will make it easier to use.
I just give you some suggestions for improvement, if you do not accept, I can do nothing.

@NavpreetDevpuri
Copy link
Contributor Author

let me think about it
what you want to suggest ?
may be i can just leave Dots in Text and use remove_invisible_chars()

@PgBiel
Copy link
Member

PgBiel commented Jun 7, 2020

It is in our guidelines to include documentation in your PR. You can take all the time you want for that, don't worry

@NavpreetDevpuri
Copy link
Contributor Author

@PgBiel please review documentions of Code().
is it Ok ?

@NavpreetDevpuri
Copy link
Contributor Author

This is my first documentation.

Copy link
Member

@PgBiel PgBiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that's a very good first try, and I congratulate you for that. I have a few complaints, though, but nothing that can't be solved... (WIll attempt to take a better look later)

TEXT_MOB_SCALE_FACTOR = 0.05


def remove_invisible_chars(mobject):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a little docstring could be useful here

@NavpreetDevpuri
Copy link
Contributor Author

Thanku @PgBiel for that.
Thats great !

@PgBiel
Copy link
Member

PgBiel commented Jun 23, 2020

You're welcome! Make sure to take a look at each of the suggestions, and tell me if any questions remain.

@safinsingh
Copy link
Contributor

@NavpreetDevpuri can you please bring this up to date with master?

@NavpreetDevpuri
Copy link
Contributor Author

NavpreetDevpuri commented Jul 12, 2020

@safinsingh done reopened #198

@NavpreetDevpuri
Copy link
Contributor Author

Is https://github.com/3b1b/manim no longer in developement ?

@Aathish04
Copy link
Member

Is https://github.com/3b1b/manim no longer in developement ?

It is still in development, see the shaders branch there. It's just that the de facto only developer there is 3b1b ;)

@NavpreetDevpuri
Copy link
Contributor Author

NavpreetDevpuri commented Jul 12, 2020

alright understood, here we are developing this library further according to our needs and creativity and the main repo is used by 3b1b so he will be developing it according to his own requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Additions and improvements in general pr:bugfix Bug fix for use in PRs solving a specific issue:bug refactor Refactor or redesign of existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some bugs of code_mobject.py

7 participants