Skip to content

Conversation

@TurkeyBilly
Copy link
Contributor

Added config passing for text

Motivation

Give users option to change the text config for DecimalNumber

Proposed changes

  • Added text_config in decimal number config
  • Removed extra init_colors() so that t2c can be passed in
  • Adjustedstring_to_mob method so key word arguments can be accepted, meanwhile maintain the string_to_mob_map

Test

Code:

class Test(Scene):
    def construct(self):
        a = DecimalNumber(1.02, show_ellipsis=True)
        b = DecimalNumber(1.02, show_ellipsis=True, 
                            text_config=dict(font="仿宋", slant=ITALIC)).shift(DOWN)
        c = DecimalNumber(1.02, show_ellipsis=True, 
                            text_config=dict(font="Times New Romen", t2c={'0':RED})).shift(2*DOWN)
        self.add(a, b, c)

Result:
image

@3b1b 3b1b merged commit a4eee6f into 3b1b:master Feb 15, 2022
TonyCrane added a commit that referenced this pull request Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants