Fix Write()
stroke width to scale with font_size
or object scale
#4222
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.
Overview: What does this pull request change?
Motivation and Explanation: Why and how do your changes improve the library?
Previously, the stroke effect was hardcoded and appeared too thick on small fonts and too thin on large ones.
This PR introduces a helper method
_adjust_stroke_width_for_text()
that dynamically adjusts the stroke width based on the font size of the text, proportionally scaled to 25% of the default stroke width.The adjustment only applies when:
font_size
is too small, such as below20
, so zooming-in is needed.font_size
is too big, but this is actually not a problem, but scalingstroke_width
make it look better.stroke_width
is not explicitly provided by the user.For all other cases, the
stroke_width
is2.0
(default fromDrawBorderThenFill
), and behaves like before this change.Links to added or changed documentation pages
https://manimce--4222.org.readthedocs.build/en/4222/reference/manim.animation.creation.Write.html
Further Information and Comments
Test:
Before the fix:
WriteBug2.mp4
After the fix:
WriteBugSolution.mp4
Reviewer Checklist