Conversation
Owner
|
This looks great, thanks for doing it |
Owner
Collaborator
Author
|
Yes, it's because the styles are defined by the css in the <style> tag, which is not handled yet (nor is ManimCommunity). I'll try my best to handle this situation when I have time :) |
Owner
|
I agree it seems a little tricky. I mostly just wanted to keep track of an edge case here, don't feel like it's something you have to do. Also, just FYI, I made a few quick fixes based on its behavior with Text and MTex |
TonyCrane
added a commit
that referenced
this pull request
Jan 27, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Before,
SVGMobjectwill remove all styles from a svg file.This pull request parse the style for SVG by refering to ManimCommunity/manim.
In order to prevent the style generated layer by layer in
init_pointsfrom being globally overwritten by theinit_colorsafter it. I added a parameteroverridetoinit_colors, which is set toTrueby default (that is, consistent with the original performance), but whenoverride = False, it will recurse layer by layer and set the color to the currently generated color.Proposed changes
manimlib/mobject/svg/svg_mobject.py: add SVG style parser and fix some bugs of path stringmanimlib/mobject/types/vectorized_mobject.py: addoverrideparameter toinit_colorsmanimlib/mobject/mobject.py: synchronously update the parameters ofinit_colorsmanimlib/mobject/geometry.py: synchronously update the parameters ofinit_colorsmanimlib/mobject/types/surface.py: synchronously update the parameters ofinit_colorsmanimlib/mobject/svg/tex_mobject.py: synchronously update the parameters ofinit_colorsand synchronizeSingleStringTex'sstroke_widthtoSVGMobjectmanimlib/mobject/svg/tex_mobject.py: cache color intex_string_to_mob_maptogether with tex_stringmanimlib/mobject/svg/text_mobject.py: replacewarnings.warnwithlog.warningTest
I tested all the svg files used in ManimCE for testing and each file renders correctly with color and stroke.
And
TexTexTextcan correctly generate texts with color according to the corresponding LaTeX expression (\color{})Code:
Result:

As can be seen from the above example, the color parameter is only the default color, and this color will be overwritten as long as a color is included in the SVG. If you want to ignore the color in SVG, you can directly
.set_coloragain.