-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Changes from 2 commits
bec16f2
561afc9
b6f527b
4b4b886
1a19b41
c4ca277
3c6cf94
e027a21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -105,6 +105,11 @@ def resolution(self) -> Tuple[int, int]: | |||||||||||||
"""Returns the resolution.""" | ||||||||||||||
return self.config.resolution | ||||||||||||||
|
||||||||||||||
@property | ||||||||||||||
def background_color(self) -> str: | ||||||||||||||
"""Returns the background color.""" | ||||||||||||||
return self.config.background_color | ||||||||||||||
|
||||||||||||||
@property | ||||||||||||||
def current_slide_index(self) -> int: | ||||||||||||||
return self.__current_slide_index | ||||||||||||||
|
@@ -647,7 +652,9 @@ def __init__( | |||||||||||||
self.label.setScaledContents(True) | ||||||||||||||
self.label.setAlignment(Qt.AlignCenter) | ||||||||||||||
self.label.resize(self.display_width, self.display_height) | ||||||||||||||
self.label.setStyleSheet(f"background-color: {background_color}") | ||||||||||||||
self.label.setStyleSheet( | ||||||||||||||
f"background-color: {self.thread.current_presentation.background_color}" | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
self.pixmap = QPixmap(self.width(), self.height()) | ||||||||||||||
self.label.setPixmap(self.pixmap) | ||||||||||||||
|
@@ -727,6 +734,9 @@ def update_canvas(self) -> None: | |||||||||||||
self.display_width, self.display_height = self.thread.current_resolution | ||||||||||||||
if not self.isFullScreen(): | ||||||||||||||
self.resize(self.display_width, self.display_height) | ||||||||||||||
self.label.setStyleSheet( | ||||||||||||||
f"background-color: {self.thread.current_presentation.background_color}" | ||||||||||||||
) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For readability, create a |
||||||||||||||
|
||||||||||||||
|
||||||||||||||
@click.command() | ||||||||||||||
|
@@ -922,8 +932,8 @@ def str_to_int_or_none(value: str) -> Optional[int]: | |||||||||||||
"background_color", | ||||||||||||||
metavar="COLOR", | ||||||||||||||
type=str, | ||||||||||||||
default="black", | ||||||||||||||
help='Set the background color for borders when using "keep" resize mode. Can be any valid CSS color, e.g., "green", "#FF6500" or "rgba(255, 255, 0, .5)".', | ||||||||||||||
default=None, | ||||||||||||||
help='Set the background color for borders when using "keep" resize mode. Can be any valid CSS color, e.g., "green", "#FF6500" or "rgba(255, 255, 0, .5)". If not set, it defaults to the background color configured in the Manim scene.', | ||||||||||||||
show_default=True, | ||||||||||||||
) | ||||||||||||||
@click.option( | ||||||||||||||
|
@@ -978,7 +988,7 @@ def present( | |||||||||||||
hide_mouse: bool, | ||||||||||||||
aspect_ratio: str, | ||||||||||||||
resize_mode: str, | ||||||||||||||
background_color: str, | ||||||||||||||
background_color: Optional[str], | ||||||||||||||
start_at: Tuple[Optional[int], Optional[int], Optional[int]], | ||||||||||||||
start_at_scene_number: Optional[int], | ||||||||||||||
start_at_slide_number: Optional[int], | ||||||||||||||
|
@@ -1003,6 +1013,10 @@ def present( | |||||||||||||
for presentation_config in presentation_configs: | ||||||||||||||
presentation_config.resolution = resolution | ||||||||||||||
|
||||||||||||||
if background_color is not None: | ||||||||||||||
for presentation_config in presentation_configs: | ||||||||||||||
presentation_config.background_color = background_color | ||||||||||||||
|
||||||||||||||
Comment on lines
+1024
to
+1027
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to remove the |
||||||||||||||
presentations = [ | ||||||||||||||
Presentation(presentation_config) | ||||||||||||||
for presentation_config in presentation_configs | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work because the manim-slides/manim_slides/slide.py Lines 57 to 63 in 2a327c4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I Didn't know, understood! |
||||||||||||||||
|
||||||||||||||||
@property | ||||||||||||||||
def __resolution(self) -> Tuple[int, int]: | ||||||||||||||||
|
@@ -321,7 +322,10 @@ def __save_slides(self, use_cache: bool = True) -> None: | |||||||||||||||
with open(slide_path, "w") as f: | ||||||||||||||||
f.write( | ||||||||||||||||
PresentationConfig( | ||||||||||||||||
slides=self.__slides, files=files, resolution=self.__resolution | ||||||||||||||||
slides=self.__slides, | ||||||||||||||||
files=files, | ||||||||||||||||
resolution=self.__resolution, | ||||||||||||||||
background_color=self.__background_color, | ||||||||||||||||
).json(indent=2) | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the
Color
type from Pydantic: https://docs.pydantic.dev/usage/types/#color-type.