Skip to content

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

Open
@ccalauzenes

Description

@ccalauzenes

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions