Skip to content

Argument scale_stroke of scale method does not behaves as expected on a VGroup #4229

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

Open
ccalauzenes opened this issue Apr 27, 2025 · 0 comments · May be fixed by #4231
Open

Argument scale_stroke of scale method does not behaves as expected on a VGroup #4229

ccalauzenes opened this issue Apr 27, 2025 · 0 comments · May be fixed by #4231

Comments

@ccalauzenes
Copy link

Description of bug / unexpected behavior

When using the method scale(k, scale_stroke=True)on a VGroup, the submobjects stroke_width are all set to the one of the VGroup (default 4) and then rescaled, even if they were having different stroke_width before.

Expected behavior

When applying the method scale(k, scale_stroke=True) to a VGroup, the submobjects should have their stroke_width rescale proportionally to their initial individual stroke_width. Especially, scale(1.0, scale_stroke=True) shouldn't change the submobjects (see code example)

How to reproduce the issue

See code example.

Code for reproducing the problem
from manim import *

class TestScene(Scene):
    def construct(self):
        
        dot = Dot(radius=1)
        line = Line(ORIGIN, 2*DOWN, stroke_width=200)

        self.play(FadeIn(dot, line))
        self.wait(1)
        self.play(line.animate.scale(1, scale_stroke=True).set_color(RED))
        self.wait(1)
        self.play(VGroup(dot, line).animate.scale(1, scale_stroke=True).set_color(BLUE))
        self.wait(1)

System specifications

System Details

Environment is the official Manim docker image used as a devcontainer on MacOS 15.4.1 (Sequoia)

Additional comments

When calling scale(k, scale_stroke=True) the method scale calls the method set_stroke with the value abs(scale_factor) * self.get_stroke_width() computed on the current MObject (the VGroup).

if scale_stroke:
self.set_stroke(width=abs(scale_factor) * self.get_stroke_width())
self.set_stroke(
width=abs(scale_factor) * self.get_stroke_width(background=True),
background=True,
)
super().scale(scale_factor, **kwargs)
return self

But because the current MObject is a VGroup, this value is then propagated to all submobjects:

if family:
for submobject in self.submobjects:
submobject.set_stroke(color, width, opacity, background, family)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

1 participant