ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
20.94k stars 1.52k forks source link

Adding a TexMObject to keep formula parts in place? #3225

Open sambaPython24 opened 1 year ago

sambaPython24 commented 1 year ago

Description of proposed feature

Hey, I would like to do what has been done in this post https://github.com/3b1b/manim/issues/657 So far, I am using

eq1 = MathTex(r"A",r"=",r"\int",r"\text d x",r"f(x)", color = BLACK)
eq2 = MathTex(r"A",r"=",r"\sum + \gamma - \eta + \elta",r"\text d x",r"f(x)", color = BLACK)

self.play(
    TransformMatchingTex(eq1,  eq2),
                            run_time = 0.2
         )

but this is not really working if an element of the MathTex that is not the last changes in size, in particular when it is in the frac operator: The other parts of the formula shift or even transform as well on the screen.

How can I keep certain elements at a fixed position, like the nominator in this case?

How can the new feature be used?

It can be used to fix certain parts of the formula while changing other parts. Overall, you gain more influence over the formula.

Additional comments

MrDiver commented 9 months ago

The transformation system should be reworked on that part, we had some discussions for this on discord.

One thing that could be done in general is something like a mapping function with the indices provided by the VGroup, we will look at this in the future!