From b7bd40a6f6af9ec56237529ba954935c62b51d12 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Sat, 16 Jan 2021 10:46:30 +0800 Subject: [PATCH] make window_position changeable --- custom_defaults.yml | 4 ++++ manimlib/config.py | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/custom_defaults.yml b/custom_defaults.yml index 7c3d03f6..c2ff3a09 100644 --- a/custom_defaults.yml +++ b/custom_defaults.yml @@ -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" diff --git a/manimlib/config.py b/manimlib/config.py index cc5126ef..d5e74af3 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -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,