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

Allow disabling color inheritance for TeX mobjects #3643

Closed

Conversation

microlith57
Copy link

@microlith57 microlith57 commented Mar 15, 2024

Overview: What does this pull request change?

  • Add a preserve_colors parameter to SingleStringMathTex, allowing the user to disable color inheritance
  • Add a Parameters section to SingleStringMathTex's docstring
  • Add demos to the Extra LaTeX Packages section of the guide on using text, showing how to use xcolor to apply colors to TeX strings

Motivation and Explanation: Why and how do your changes improve the library?

This makes it easier to color parts of TeX mobjects; for example users can define custom TeX commands in their template (like \newcommand{\X}{\ensuremath{\textcolor{cyan}{X}}} to allow \X to produce a cyan math-mode X).
This also avoids issues like #3492, #3548 by allowing TeX itself to apply the colors.

Links to added or changed documentation pages

https://manimce--3643.org.readthedocs.build/en/3643/reference/manim.mobject.text.tex_mobject.SingleStringMathTex.html

https://manimce--3643.org.readthedocs.build/en/3643/guides/using_text.html#extra-latex-packages

Further Information and Comments

Render of passing test case (upper is inheriting color, lower is preserving it):
image
Note that, without further changes to the preamble / SVG reading, any TeX not explicitly colored is black and thus invisible against the default background.

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@MrDiver
Copy link
Collaborator

MrDiver commented Apr 1, 2024

Can you explain the issue that is being solved with that ?
Because normally you would change the colors on the Mobjects that are created and not directly in the TeX code. Is there something that doesn't work when doing it with Mobject Coloring?

Additionally it would be a good idea to either, make a PR a draft if it is not ready for review, otherwise it would be great if you have working tests, run pytest for this in your poetry environment.

You might also open a corresponding issue, where the idea can be discussed with the Devs and the Community, this saves us time on all sides, and also prevents you from investing your time in a PR which might not be accepted.

Thanks for participating in contributing to Manim! ✨

@MrDiver MrDiver marked this pull request as draft April 1, 2024 02:24
@behackl
Copy link
Member

behackl commented Apr 24, 2024

Seems to have gone stale; I'm closing this until there is more information about the concrete use case for this feature.

@behackl behackl closed this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

None yet

3 participants