Commit: 577391eb0ca7e74244de3caa3e6344b9acfbf161
Parent: f0a0f38dfca2b25c62c8a81b3cba4cda03417b6d
Author: Randy Palamar
Date: Wed, 21 Aug 2024 10:02:03 -0600
simplify corner calculation
Diffstat:
M | vtgl.c | | | 34 | ++++++++++++++-------------------- |
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/vtgl.c b/vtgl.c
@@ -70,34 +70,28 @@ get_cell_size(Term *t)
}
static v2
+get_occupied_size(Term *t)
+{
+ v2 cs = get_cell_size(t);
+ v2 result = {.x = t->size.w * cs.w, .y = t->size.h * cs.h};
+ return result;
+}
+
+static v2
get_terminal_top_left(Term *t)
{
- v2 cs = get_cell_size(t);
- v2 occupied_size = {.x = t->size.w * cs.w, .y = t->size.h * cs.h};
- v2 delta = {
- .x = t->gl.window_size.w - 2 * g_term_pad.w - occupied_size.w,
- .y = t->gl.window_size.h - 2 * g_term_pad.h - occupied_size.h
- };
- v2 result = {
- .x = g_term_pad.w + delta.x / 2,
- .y = t->gl.window_size.h - g_term_pad.h - delta.y / 2
- };
+ v2 os = get_occupied_size(t);
+ v2 delta = {.x = t->gl.window_size.w - os.w, .y = t->gl.window_size.h - os.h};
+ v2 result = {.x = delta.x / 2, .y = t->gl.window_size.h - delta.y / 2};
return result;
}
static v2
get_terminal_bot_left(Term *t)
{
- v2 cs = get_cell_size(t);
- v2 occupied_size = {.x = t->size.w * cs.w, .y = t->size.h * cs.h};
- v2 delta = {
- .x = t->gl.window_size.w - 2 * g_term_pad.w - occupied_size.w,
- .y = t->gl.window_size.h - 2 * g_term_pad.h - occupied_size.h
- };
- v2 result = {
- .x = g_term_pad.w + delta.x / 2,
- .y = g_term_pad.h + delta.y / 2
- };
+ v2 os = get_occupied_size(t);
+ v2 delta = {.x = t->gl.window_size.w - os.w, .y = t->gl.window_size.h - os.h};
+ v2 result = {.x = delta.x / 2, .y = delta.y / 2};
return result;
}