Attempt to refactor SVGMobject with svgelements#1731
Merged
3b1b merged 25 commits into3b1b:masterfrom Feb 11, 2022
YishiMichael:master
Merged
Attempt to refactor SVGMobject with svgelements#17313b1b merged 25 commits into3b1b:masterfrom YishiMichael:master
3b1b merged 25 commits into3b1b:masterfrom
YishiMichael:master
Conversation
TonyCrane
approved these changes
Feb 11, 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
Try using external library
svgelementsto refactor SVGMobject.Proposed changes
manimlib/mobject/svg/svg_mobject.py: usesvgelementsto parse svg filesmanimlib/mobject/svg/tex_mobject.py: removeoverrideattribute frominit_colorsmethod; cut off global style-applying process frominit_colorsmanimlib/mobject/svg/text_mobject.py: removeinit_colorsinheritance; addset_fillprocess since svg files rendered byTexthave the black color specifiedmanimlib/mobject/svg/mtex_mobject.py: replace.fill_colorwith.get_fill_color()manimlib/mobject/mobject.py: removeoverrideattribute frominit_colorsmethodmanimlib/mobject/geometry.py: addPolylineclass; removeoverrideattribute frominit_colorsmethodmanimlib/mobject/types/surface.py: removeoverrideattribute frominit_colorsmethodmanimlib/mobject/types/vectorized_mobject.py: removeoverrideattribute frominit_colorsmethodrequirements.txt: update requirements (addsvgelements, removecssselect2)setup.cfg: update requirements (addsvgelements, removecssselect2)Notes
SVGMobject, 5 attributes (fill_color,fill_opacity,stroke_width,stroke_color,stroke_opacity) depend on the result of style parsing. If not specified, they will be set as default attributes passed toSVGMobjectclass.set_fill,set_strokemethods can still apply style globally.unpack_groupsattribute is removed as the structure may be modified. NowSVGMobjectalways unpacks submobjects.MarkupText, just likeText, but I cannot runMarkupTextand cannot look into svg files rendered by it.<text>tags in svg are still not handled.SingleStringTexandMTexboth inherit fromSVGMobject, and in community edition they do. This may also be handled later.