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

feat(cli/lib): use scene background color as default #160

Merged
merged 8 commits into from
Mar 22, 2023

Conversation

Fairlight8
Copy link
Contributor

@Fairlight8 Fairlight8 commented Mar 17, 2023

Fixes Issue

Closes #130

Check List (Check all the applicable boxes)

  • I understand that my contributions needs to pass the checks.
  • If I created new functions / methods, I documented them and add type hints.
  • If I modified already existing code, I updated the documentation accordingly.
  • The title of my pull request is a short description of the requested changes.

Note to reviewers

Please review the code, just in case ^^

@pre-commit-ci pre-commit-ci bot temporarily deployed to github-pages March 17, 2023 00:22 Inactive
Copy link
Owner

@jeertmans jeertmans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work @Fairlight8, I requested a few changes before I can merge :-)

@@ -150,6 +150,7 @@ class PresentationConfig(BaseModel): # type: ignore
slides: List[SlideConfig]
files: List[FilePath]
resolution: Tuple[PositiveInt, PositiveInt] = (1920, 1080)
background_color: str = "black"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
background_color: str = "black"
background_color: str = Color

Please use the Color type from Pydantic: https://docs.pydantic.dev/usage/types/#color-type.

Comment on lines 737 to 739
self.label.setStyleSheet(
f"background-color: {self.thread.current_presentation.background_color}"
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.label.setStyleSheet(
f"background-color: {self.thread.current_presentation.background_color}"
)
self.label.setStyleSheet(
f"background-color: {self.thread.current_background_color}"
)

For readability, create a current_background_color property :-)

@@ -53,6 +53,7 @@ def __init__(
self.__current_animation = 0
self.__loop_start_animation: Optional[int] = None
self.__pause_start_animation = 0
self.__background_color = config["background_color"].hex
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work because the background_color attribute is not placed in config with ManimGL. So you need to a separate implementation, as with __resolution:

@property
def __resolution(self) -> Tuple[int, int]:
"""Returns the scene's resolution used during rendering."""
if MANIMGL:
return self.camera_config["pixel_width"], self.camera_config["pixel_height"]
else:
return config["pixel_width"], config["pixel_height"]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I Didn't know, understood!

Comment on lines +1016 to +1019
if background_color is not None:
for presentation_config in presentation_configs:
presentation_config.background_color = background_color

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to remove the background_color option from App :-)

@Fairlight8
Copy link
Contributor Author

Of course, of course. Sorry for the potential mistakes. It is a simple issue but I am still new contributing to other projects.

I agree with all the changes. Do I have to accept them?

@jeertmans
Copy link
Owner

No problem, first contributions are always hard!

In general, you can approve them, yes. But here, some codes changes are still needed beyond those I proposed. For example, you need to import the Color from pydantic first :)

@jeertmans jeertmans added enhancement New feature or request present Related to the main "present" feature labels Mar 17, 2023
@Fairlight8
Copy link
Contributor Author

Ohhhh, true true true. So, what's the process now? Should I add a different PR? Add new commits? Can I change this PR for another commit?

@jeertmans
Copy link
Owner

You can just push new commits :)

@jeertmans jeertmans changed the title Use scene background color as default feat(cli/lib): scene background color as default Mar 20, 2023
@jeertmans jeertmans changed the title feat(cli/lib): scene background color as default feat(cli/lib): use scene background color as default Mar 20, 2023
@Fairlight8 Fairlight8 temporarily deployed to github-pages March 21, 2023 23:16 — with GitHub Actions Inactive
@pre-commit-ci pre-commit-ci bot temporarily deployed to github-pages March 22, 2023 00:33 Inactive
@Fairlight8
Copy link
Contributor Author

Added some changes! I think that's fine now!

manim_slides/slide.py Outdated Show resolved Hide resolved
manim_slides/slide.py Outdated Show resolved Hide resolved
manim_slides/slide.py Outdated Show resolved Hide resolved
@jeertmans
Copy link
Owner

Nice work! A few last changes before merging this were requested. You can see that pre-commit.ci does some type checking, and a few errors were pointed-out: https://results.pre-commit.ci/run/github/513032928/1679445219.3lZ-NZzDS-2nlcoJtXckeQ.

You can just approve the changes if you agree with them.

@Fairlight8 Fairlight8 temporarily deployed to github-pages March 22, 2023 11:23 — with GitHub Actions Inactive
@Fairlight8
Copy link
Contributor Author

Another commit for those details. By the way. The github pages thing is my issue, right?

@jeertmans
Copy link
Owner

Another commit for those details. By the way. The github pages thing is my issue, right?

You don't have to mind about that :-)

manim_slides/slide.py Outdated Show resolved Hide resolved
@jeertmans jeertmans temporarily deployed to github-pages March 22, 2023 11:59 — with GitHub Actions Inactive
manim_slides/slide.py Outdated Show resolved Hide resolved
@jeertmans jeertmans temporarily deployed to github-pages March 22, 2023 12:07 — with GitHub Actions Inactive
@Fairlight8
Copy link
Contributor Author

Goodness, too many new things xDDD. That is already changed, right? I pulled from git and it is already changed.

@jeertmans
Copy link
Owner

Yep sorry, I didn't want to bother you, so I committed the changes directly ^^

Looks good to me, I will merge this and soon release this :-) Probably as part of 4.12

@jeertmans jeertmans merged commit 88d5987 into jeertmans:main Mar 22, 2023
@Fairlight8
Copy link
Contributor Author

Understood, thank you! Again, thanks a lot for your patience. Probably, it would be much more shorter and easier if you did that on your own, so I appreciate the patience while I learn all these things!

@jeertmans
Copy link
Owner

No problem, it was a pleasure :-) I've been there too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request present Related to the main "present" feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] read background color from manim.config, save it in config and use it in Manim-Slides
2 participants