ManimCommunity / ManimCommunity/manim

`DecimalNumber.set_value` ignores rotation

Open
#4,830 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

Description of bug / unexpected behavior

DecimalNumber.set_value ignores the rotation of the original number.

This leads to the changed number not being rotated and being scaled to the "rotated size".

class TestScene(Scene):
    def construct(self) -> None:
        number = DecimalNumber(font_size=192)
        self.add(number)
        self.play(Rotate(number, 45 * DEGREES))
        number.set_value(1)
        self.wait()

https://github.com/user-attachments/assets/652e6518-8b15-4f32-afad-9841ecc0027c

Expected behavior

The decimal number should have:

  • The same rotation
  • The same size (font size, scale, etc.)

How to reproduce the issue

Code for reproducing the problem
class DetailedTestScene(Scene):
    def construct(self) -> None:
        number_1 = DecimalNumber()
        number_2 = DecimalNumber()
        number_3 = DecimalNumber()
        VGroup(number_1, number_2, number_3).arrange(RIGHT, buff=1.5)

        self.add(number_1, number_2, number_3)
        self.wait()

        number_1.rotate(45 * DEGREES)
        self.play(
            number_2.animate.rotate(45 * DEGREES),
            Rotate(number_3, 45 * DEGREES),
        )
        self.wait()

        number_1.set_value(1)
        self.play(
            number_2.animate.set_value(1),
            ChangeDecimalToValue(number_3, 1),
        )
        self.wait()

https://github.com/user-attachments/assets/78350f62-7a26-49a2-aabc-cf81b2146c84

Additional comments

Manim would probably need to keep track of things like scale and rotation to prevent this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with DecimalNumber.set_value and the provided TestScene or DetailedTestScene, then trace DecimalNumber and ChangeDecimalToValue behavior. Done means updating a rotated DecimalNumber preserves its rotation and visual size, including when changed directly or through animation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.