Skip to content

Commit cb6a5bb

Browse files
feat: add option for background color (#60)
* feat: add option for background color This allows to define the background color used for border when resize mode is set to "keep". Closes #52 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bba05cc commit cb6a5bb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

manim_slides/present.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ def __init__(
528528
hide_mouse: bool = False,
529529
aspect_ratio: Qt.AspectRatioMode = Qt.IgnoreAspectRatio,
530530
resize_mode: Qt.TransformationMode = Qt.SmoothTransformation,
531+
background_color: str = "black",
531532
**kwargs,
532533
):
533534
super().__init__()
@@ -544,6 +545,7 @@ def __init__(
544545
self.label = QLabel(self)
545546
self.label.setAlignment(Qt.AlignCenter)
546547
self.label.resize(self.display_width, self.display_height)
548+
self.label.setStyleSheet(f"background-color: {background_color}")
547549

548550
self.pixmap = QPixmap(self.width(), self.height())
549551
self.label.setPixmap(self.pixmap)
@@ -725,6 +727,16 @@ def _list_scenes(folder) -> List[str]:
725727
help="Set the resize (i.e., transformation) mode to be used when rescaling video.",
726728
show_default=True,
727729
)
730+
@click.option(
731+
"--background-color",
732+
"--bgcolor",
733+
"background_color",
734+
metavar="COLOR",
735+
type=str,
736+
default="black",
737+
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)".',
738+
show_default=True,
739+
)
728740
@click.help_option("-h", "--help")
729741
@verbosity_option
730742
def present(
@@ -740,6 +752,7 @@ def present(
740752
hide_mouse,
741753
aspect_ratio,
742754
resize_mode,
755+
background_color,
743756
) -> None:
744757
"""
745758
Present SCENE(s), one at a time, in order.
@@ -832,6 +845,7 @@ def value_proc(value: str) -> List[str]:
832845
hide_mouse=hide_mouse,
833846
aspect_ratio=ASPECT_RATIO_MODES[aspect_ratio],
834847
resize_mode=RESIZE_MODES[resize_mode],
848+
background_color=background_color,
835849
)
836850
a.show()
837851
sys.exit(app.exec_())

0 commit comments

Comments
 (0)