mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-21 04:26:40 +08:00
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>
This commit is contained in:
@ -528,6 +528,7 @@ class App(QWidget):
|
|||||||
hide_mouse: bool = False,
|
hide_mouse: bool = False,
|
||||||
aspect_ratio: Qt.AspectRatioMode = Qt.IgnoreAspectRatio,
|
aspect_ratio: Qt.AspectRatioMode = Qt.IgnoreAspectRatio,
|
||||||
resize_mode: Qt.TransformationMode = Qt.SmoothTransformation,
|
resize_mode: Qt.TransformationMode = Qt.SmoothTransformation,
|
||||||
|
background_color: str = "black",
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -544,6 +545,7 @@ class App(QWidget):
|
|||||||
self.label = QLabel(self)
|
self.label = QLabel(self)
|
||||||
self.label.setAlignment(Qt.AlignCenter)
|
self.label.setAlignment(Qt.AlignCenter)
|
||||||
self.label.resize(self.display_width, self.display_height)
|
self.label.resize(self.display_width, self.display_height)
|
||||||
|
self.label.setStyleSheet(f"background-color: {background_color}")
|
||||||
|
|
||||||
self.pixmap = QPixmap(self.width(), self.height())
|
self.pixmap = QPixmap(self.width(), self.height())
|
||||||
self.label.setPixmap(self.pixmap)
|
self.label.setPixmap(self.pixmap)
|
||||||
@ -725,6 +727,16 @@ def _list_scenes(folder) -> List[str]:
|
|||||||
help="Set the resize (i.e., transformation) mode to be used when rescaling video.",
|
help="Set the resize (i.e., transformation) mode to be used when rescaling video.",
|
||||||
show_default=True,
|
show_default=True,
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--background-color",
|
||||||
|
"--bgcolor",
|
||||||
|
"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)".',
|
||||||
|
show_default=True,
|
||||||
|
)
|
||||||
@click.help_option("-h", "--help")
|
@click.help_option("-h", "--help")
|
||||||
@verbosity_option
|
@verbosity_option
|
||||||
def present(
|
def present(
|
||||||
@ -740,6 +752,7 @@ def present(
|
|||||||
hide_mouse,
|
hide_mouse,
|
||||||
aspect_ratio,
|
aspect_ratio,
|
||||||
resize_mode,
|
resize_mode,
|
||||||
|
background_color,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Present SCENE(s), one at a time, in order.
|
Present SCENE(s), one at a time, in order.
|
||||||
@ -832,6 +845,7 @@ def present(
|
|||||||
hide_mouse=hide_mouse,
|
hide_mouse=hide_mouse,
|
||||||
aspect_ratio=ASPECT_RATIO_MODES[aspect_ratio],
|
aspect_ratio=ASPECT_RATIO_MODES[aspect_ratio],
|
||||||
resize_mode=RESIZE_MODES[resize_mode],
|
resize_mode=RESIZE_MODES[resize_mode],
|
||||||
|
background_color=background_color,
|
||||||
)
|
)
|
||||||
a.show()
|
a.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
Reference in New Issue
Block a user