make window_position changeable

This commit is contained in:
Tony031218 2021-01-16 10:46:30 +08:00
parent 453ccc2765
commit b7bd40a6f6
2 changed files with 21 additions and 1 deletions

View file

@ -29,6 +29,10 @@ universal_import_line: "from manimlib.imports import *"
style:
font: "Consolas"
background_color: "#333333"
# Set the position of preview window, you can use directions, e.g. UL/DR/OL/OO/...
# also, you can also specify the position(pixel) of the upper left corner of
# the window on the monitor, e.g. "960,540"
window_position: UR
camera_qualities:
low:
resolution: "854x480"

View file

@ -203,7 +203,23 @@ def get_configuration(args):
else:
window_width = monitor.width / 2
window_height = window_width * 9 / 16
window_position = (int(monitor.width - window_width), 0)
custom_position = custom_defaults["window_position"]
if "," in custom_position:
posx, posy = map(int, custom_position.split(","))
else:
if custom_position[1] == "L":
posx = 0
elif custom_position[1] == "O":
posx = int((monitor.width - window_width) / 2)
elif custom_position[1] == "R":
posx = int(monitor.width - window_width)
if custom_position[0] == "U":
posy = 0
elif custom_position[0] == "O":
posy = int((monitor.height - window_height) / 2)
elif custom_position[0] == "D":
posy = int(monitor.height - window_height)
window_position = (posx, posy)
config["window_config"] = {
"size": (window_width, window_height),
"position": window_position,