ManimCommunity / ManimCommunity/manim

DecimalNumber() updater font size dependent on placement when using unit="°"

Open
#3,217 1 comment 1 reaction 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
The font size of a `DecimalNumber()` object changes when updated when it is placed using `.next_to()` to an object which itself was placed relative to the top-left corner using `to_edge(UL)`.

## Expected behavior
The font size of the `DecimalNumber()` should not change when its value is updated.

## How to reproduce the issue

Code for reproducing the problem

```py

class decupdate2(Scene):
def construct(self):
x = ValueTracker(2)

theta = MathTex(r"\theta =").to_corner(UL)

theta2val = DecimalNumber(
0, num_decimal_places=1, group_with_commas=False, unit="°", edge_to_fix=LEFT
).next_to(theta, RIGHT)

def theta2Updater(mobj):
mobj.set_value(np.arctan2(3,x.get_value())*180/PI)

theta2val.add_updater(theta2Updater)

self.add(theta,theta2val)
self.wait()
self.play(x.animate.set_value(6),run_time=3)
self.wait()
```
Similar code - only difference is the placement of the object next to the DecimalNumber()

```py
class decupdate3(Scene):
def construct(self):
x = ValueTracker(2)

theta = MathTex(r"\theta =").to_edge(LEFT)

theta2val = DecimalNumber(
0, num_decimal_places=1, group_with_commas=False, unit="°", edge_to_fix=LEFT
).next_to(theta, RIGHT)

def theta2Updater(mobj):
mobj.set_value(np.arctan2(3,x.get_value())*180/PI)

theta2val.add_updater(theta2Updater)

self.add(theta,theta2val)
self.wait()
self.play(x.animate.set_value(6),run_time=3)
self.wait()
```

## Additional media files
Images/GIFs
With the wrong scaling:

![image](https://user-images.githubusercontent.com/8582807/232905335-a56142f2-8ecc-4b35-97dd-9dcbdf39daff.png)

Second code without wrong scaling

![image](https://user-images.githubusercontent.com/8582807/232905438-6ba3ae03-729f-4821-91d3-0b37bc4ace87.png)

## System specifications

System Details

- OS: Windows 10 and Manimator on Discord
- RAM: enough
- Python version: 3.9.8 and Manimator on Discord

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 running the two supplied Scene examples and comparing DecimalNumber() behavior when positioned with next_to() after to_corner(UL) versus to_edge(LEFT). Trace the DecimalNumber() set_value updater path alongside placement and edge_to_fix=LEFT. Done means updating the value no longer changes its font size in the reproduced placement.

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
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.