From 41650479febd0bc76fae4278ac2ae6374891543a Mon Sep 17 00:00:00 2001 From: gxalpha Date: Sun, 5 May 2024 20:42:47 +0200 Subject: [PATCH] UI: Center preview spacing lines Currently, the spacing lines begin in the middle of the box and then are their width wide towards one direction. This means that the larger they are, the more off-center their middle is. This commit changes them to start at half their width left/top of the center and end half the width to the right/bottom of the center, putting the middle in the center. --- UI/window-basic-preview.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index 54daacdab..042dd458a 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -1758,13 +1758,16 @@ static void DrawLine(float x1, float y1, float x2, float y2, float thickness, gs_render_start(true); - gs_vertex2f(x1, y1); - gs_vertex2f(x1 + (xSide * (thickness / scale.x)), - y1 + (ySide * (thickness / scale.y))); - gs_vertex2f(x2 + (xSide * (thickness / scale.x)), - y2 + (ySide * (thickness / scale.y))); - gs_vertex2f(x2, y2); - gs_vertex2f(x1, y1); + gs_vertex2f(x1 - (xSide * (thickness / scale.x) / 2), + y1 + (ySide * (thickness / scale.y) / 2)); + gs_vertex2f(x1 + (xSide * (thickness / scale.x) / 2), + y1 - (ySide * (thickness / scale.y) / 2)); + gs_vertex2f(x2 + (xSide * (thickness / scale.x) / 2), + y2 + (ySide * (thickness / scale.y) / 2)); + gs_vertex2f(x2 - (xSide * (thickness / scale.x) / 2), + y2 - (ySide * (thickness / scale.y) / 2)); + gs_vertex2f(x1 - (xSide * (thickness / scale.x) / 2), + y1 + (ySide * (thickness / scale.y) / 2)); gs_vertbuffer_t *line = gs_render_save();