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

Add scale_stroke boolean parameter to VMobject.scale() to allow scaling stroke_width along with the VMobject #3965

Merged
merged 13 commits into from
Oct 28, 2024

Conversation

Boris-Filin
Copy link
Contributor

@Boris-Filin Boris-Filin commented Oct 20, 2024

Overview: What does this pull request change?

This change adds an optional boolean to Mobject.scale(...), which enables outline scaling:
circle.scale(0.25, scale_stroke=True)
Leading to the following changes:
(scale_stroke=False)
image

(scale_stroke=True)
image

This supports any object that has the set_stroke(...) method.
Negative scaling does not break the stroke, however, due to the way animation is interpolated, the outline width is inconsistent in the process of negative scaling.

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

This closes #3525, adding the ability to scale an object outline.

This is a university-driven PR

(Same as my PR for 3863) Just for context, this PR (same as some other recent ones on this repo) is motivated by a university assignment that requires us to contribute to an Open-Source project. PR merge is not required, however. I figured this information might affect your judgment.

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

Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks for the PR!
It seems to me that a concept of a stroke/stroke outline is only applicable to VMobjects (Vectorized Mobjects), and doesn't make much sense in the case of an ImageMobject for example. Can you elaborate a bit more on why you choose to override the method in Mobject instead?

Also, it might be helpful to add a graphical unit test for this - see https://docs.manim.community/en/latest/contributing/testing.html#graphical-unit-test

manim/mobject/mobject.py Outdated Show resolved Hide resolved
Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good to me, thanks!
I left a couple of minor comments that it would be nice to fix before merging.
Thanks for the PR!

manim/mobject/types/vectorized_mobject.py Outdated Show resolved Hide resolved
manim/mobject/types/vectorized_mobject.py Outdated Show resolved Hide resolved
Copy link
Contributor

@chopan050 chopan050 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for commiting the changes suggested by Jason.

@chopan050 chopan050 changed the title #3525 Optionally scale outline width when object is scaled Add scale_stroke boolean parameter to VMobject.scale() to allow scaling stroke_width along with the VMobject Oct 28, 2024
@chopan050 chopan050 enabled auto-merge (squash) October 28, 2024 14:35
@chopan050 chopan050 merged commit 2570a25 into ManimCommunity:main Oct 28, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Option to scale stroke_width
3 participants