summaryrefslogtreecommitdiff
path: root/gl.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-05 14:38:19 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-05 14:38:19 -0500
commit23771a9e599700aa9c80139abb122a0f6c97976a (patch)
tree9fd67445e59e4df66a5832378ba533d6dd7c73fe /gl.c
parent3afd86c471e3ae6f806737908689a20eb686360a (diff)
fix rendering if border-thickness is big
Diffstat (limited to 'gl.c')
-rw-r--r--gl.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/gl.c b/gl.c
index a30eb59..a7f720f 100644
--- a/gl.c
+++ b/gl.c
@@ -210,17 +210,16 @@ static void gl_geometry_rect(Rect r, u32 color_rgba) {
}
static void gl_geometry_rect_border(Rect r, float border_thickness, u32 color) {
- float border_radius = border_thickness * 0.5f;
float x1 = r.pos.x, y1 = r.pos.y, x2 = x1 + r.size.x, y2 = y1 + r.size.y;
// make sure rectangle isn't too small
- x2 = maxf(x2, x1 + 2 * border_radius);
- y2 = maxf(y2, y1 + 2 * border_radius);
+ x2 = maxf(x2, x1 + border_thickness);
+ y2 = maxf(y2, y1 + border_thickness);
- gl_geometry_rect(rect4(x1+border_radius, y1-border_radius, x2+border_radius, y1+border_radius), color);
- gl_geometry_rect(rect4(x1-border_radius, y2-border_radius, x2-border_radius, y2+border_radius), color);
- gl_geometry_rect(rect4(x1-border_radius, y1-border_radius, x1+border_radius, y2-border_radius), color);
- gl_geometry_rect(rect4(x2-border_radius, y1+border_radius, x2+border_radius, y2+border_radius), color);
+ gl_geometry_rect(rect4(x1+border_thickness, y1, x2, y1+border_thickness), color);
+ gl_geometry_rect(rect4(x1, y2-border_thickness, x2-border_thickness, y2), color);
+ gl_geometry_rect(rect4(x1, y1, x1+border_thickness, y2), color);
+ gl_geometry_rect(rect4(x2-border_thickness, y1+border_thickness, x2, y2), color);
}
static void gl_geometry_draw(void) {