From 7597657af289d34d24d3b8a39ab24b3f19bff892 Mon Sep 17 00:00:00 2001 From: cadowtin Date: Tue, 2 Apr 2024 14:19:43 -0500 Subject: [PATCH] Fix offset to auto choose direction --- scripts/module.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/module.js b/scripts/module.js index 7996905..4356ab5 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -85,8 +85,8 @@ function createRulesLawyerEffect(vidFile, data, sfxFile) { const delay = getSetting("delay") * 1000; const scale = videoScale * getSetting("scale") * getSetting("player.scale"); const imgOffset = { - x: scale * videoWidth, - y: scale * videoHeight, + x: scale * videoWidth * getImageOffset(position).x, + y: scale * videoHeight * getImageOffset(position).y, }; // Create effect sequence @@ -130,6 +130,21 @@ function getAnchor(position) { } } +function getImageOffset(position) { + switch (position) { + case "bot-left": + return { x: 0, y: -1 }; + case "bot-right": + return { x: -1, y: -1 }; + case "top-left": + return { x: 0, y: 0 }; + case "top-right": + return { x: -1, y: 0 }; + default: + return { x: 0.5, y: 1 }; + } +} + function getUIOffset(position) { switch (position) { case "bot-left":