Skip to content
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

Handle explicit color-related commands #1720

Merged
merged 7 commits into from
Jan 29, 2022
Merged

Handle explicit color-related commands #1720

merged 7 commits into from
Jan 29, 2022

Conversation

YishiMichael
Copy link
Contributor

@YishiMichael YishiMichael commented Jan 27, 2022

Proposed changes

  • M manimlib/mobject/svg/mtex_mobject.py

Since MTex uses color for indexing submobjects, tex that originally brought with \color commands (or \textcolor, etc.) will cause failure. So I handled such a situation. Also, I reconstructed the algorithm in generate_tex() function, making svg files generated as few as possible.

Test

Code:

from manimlib import *


class Test(Scene):
    def construct(self):
        mtex = MTex(
            "{\\color{green} R G} {{Y}} B",
            tex_to_color_map={"R": RED},
            color=BLUE
        )
        mtex.set_color_by_tex("{{Y}}", YELLOW)
        self.add(mtex)

Result:
MathjaxTest

@TonyCrane TonyCrane requested a review from 3b1b January 27, 2022 16:21
@YishiMichael YishiMichael marked this pull request as draft January 28, 2022 15:44
@YishiMichael YishiMichael marked this pull request as ready for review January 29, 2022 06:09
@3b1b 3b1b merged commit fad9ed2 into 3b1b:master Jan 29, 2022
TonyCrane added a commit that referenced this pull request Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants