-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Completely rewrite Code
mobject + add support for short notation RGB(A) hex code specifications to ManimColor
#4115
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
Completely rewrite Code
mobject + add support for short notation RGB(A) hex code specifications to ManimColor
#4115
Conversation
for more information, see https://pre-commit.ci
…l/manim into rewrite-code-fix-color-shortcodes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested this yet, but just some stuff I saw from looking through.
On another note, since the Code
mobject has been fully rewritten, it might be a good idea to enable mypy
on it (see mypy.ini
in the root directory).
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…l/manim into rewrite-code-fix-color-shortcodes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the very needed rewriting of Code
and the support of shorter hex code colors!
I left some comments regarding Code
.
EDIT: I just noticed that, while I was writing my review and before publishing it, Jason published his own. A few of his comments are similar or even the same as mine.
Co-authored-by: Francisco Manríquez Novoa <[email protected]>
Thanks for your reviews! I've addressed all suggestions, the interface of the rewritten mobject now looks quite different than in the first version -- but I think it was improved significantly and brought in line to how other mobjects composed of different sub-mobjects like I've updated the overview in the PR description, the main takeaway is that there are now two |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I noticed we don't have any graphical tests for Code
- maybe in this PR or a followup, it might be a good idea to add one?
IIRC the issue with graphical tests was that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
See title.
Due to a version upgrade of
pygments
, support for short notation color hex codes was required -- which also required a patch toCode
. This part of this PR could be factored out (e.g., to allow us to finalize the release faster).The
Code
mobject was in a somewhat bad state, code quality wise. This re-implementation is clean(er) and easier to maintain / extend (especially considering the interest in terms of adding specific transform and highlight animations in recent PRs and issues).Note: I did not keep the interface of the old mobject -- in fact, there are several changes to the names of the keyword arguments etc., and I've also not ported all of the functionality. I'm open to porting over further features (like configureable tab width etc.) though.
Summary of breaking changes for the
Code
class, by keyword arguments. Old arguments:file_name
-- renamed tocode_file
code
-- renamed tocode_string
tab_width
-- kept as isline_spacing
-- kept, but has to be passed inside ofparagraph_config
dict nowfont_size
-- kept, but has to be passed inside ofparagraph_config
dict nowfont
-- kept, but has to be passed inside ofparagraph_config
dict nowstroke_width
-- kept, but has to be passed inside ofparagraph_config
dict nowmargin
-- renamed tobuff
and has to be passed inside ofbackground_config
dict nowindentation_chars
-- gonebackground
-- kept as isbackground_stroke_width
-- renamed tostroke_width
and has to be passed inside ofbackground_config
dict nowbackground_stroke_color
-- renamed tostroke_color
and has to be passed inside ofbackground_config
dict nowcorner_radius
-- kept, but has to be passed inside ofbackground_config
dict nowinsert_line_no
-- renamed toadd_line_numbers
line_no_from
-- renamed toline_numbers_from
line_no_buff
-- gonestyle
-- renamed toformatter_style
language
-- kept as isgenerate_html_file
-- gonewarn_missing_font
-- gone**kwargs
-- goneNew keyword arguments:
background_config
-- extra arguments passed to background mobject (currently:SurroundingRectangle
), default arguments are stored in class attributeCode.default_background_config
paragraph_config
-- extra arguments passed toParagraph
(for code and line numbers), default arguments are stored in class attributeCode.default_paragraph_config
.