Skip to content
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

Adding "label_buff" config parameter for Brace #1704

Merged
merged 3 commits into from
Jan 3, 2022
Merged

Adding "label_buff" config parameter for Brace #1704

merged 3 commits into from
Jan 3, 2022

Conversation

TurkeyBilly
Copy link
Contributor

@TurkeyBilly TurkeyBilly commented Jan 3, 2022

Motivation

-When adding a Brace Label, I can adjust the label scale and the buff between the brace and the mobject adding to. However, I can not adjust the buff between the label and the brace, which would make the distance disproportional.

-Directly using brace.scale() does not work either, as this will change the length of the brace as well.

-Meanwhile, directly passing in the argument buff=value as keyword argument will set the buff between the target mobject and the brace only. And since both methods (Brace.CONFIG and Brace.put_at_tip) use the buff keyword argument, therefore, to allow different values can be passed in for "mobject-brace buff" and "brace-label buff", this parameter is clarified as label_buff.

brace1 = BraceLabel(dl1, 'r', UP, label_scale=0.35, font_size=30, buff=0.1)

For example, the code above will result in
image
Which in this case the small 'r' is clearly too far away from the brace.

Proposed changes

  • In file manimlib.mobject.svg.brace.py, class BraceLable, added parameter label_buff in the CONFIG
  • In Line 108, pass in the parameter buff=self.label_buff for put_at_top method
  • Added import copy at the beginning

Test

Code:

brace1 = BraceLabel(dl1, 'r', UP, label_scale=0.35, font_size=30, buff=0.1, label_buff=0.1)

Result:
image

In addition, the previous version was missing an importation
before
f6cffa48c2608c43789a0e864f0db5d
after
image

@TonyCrane TonyCrane requested a review from 3b1b January 3, 2022 08:27
I misspelled "label"
added import copy
@TurkeyBilly TurkeyBilly changed the title Adding "lable_buff" config parameter for Brace Adding "label_buff" config parameter for Brace Jan 3, 2022
@3b1b 3b1b merged commit 3ffe300 into 3b1b:master Jan 3, 2022
TonyCrane added a commit that referenced this pull request Jan 27, 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.

None yet

3 participants