summaryrefslogtreecommitdiffstats
path: root/assistant/Place.js
diff options
context:
space:
mode:
Diffstat (limited to 'assistant/Place.js')
-rw-r--r--assistant/Place.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/assistant/Place.js b/assistant/Place.js
new file mode 100644
index 0000000..f6d895c
--- /dev/null
+++ b/assistant/Place.js
@@ -0,0 +1,23 @@
+.pragma library
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Top-left corner of a size x size square on a W x H screen, margin away
+// from the edges its position names. Anything unknown is the centre.
+function at(position, W, H, size, margin) {
+ const x = position.endsWith("left") ? margin
+ : position.endsWith("right") ? W - size - margin
+ : (W - size) / 2;
+ const y = position.startsWith("top") ? margin
+ : position.startsWith("bottom") ? H - size - margin
+ : (H - size) / 2;
+ return { x, y };
+}