From 2294c5c734af04a47d1bbf0c1c1621b6ad3f2ed4 Mon Sep 17 00:00:00 2001 From: Bigfoot71 Date: Wed, 8 Jan 2025 21:16:12 +0100 Subject: [PATCH] improve fix - (pixel offset issue with `DrawRectangleRoundedLinesEx`) --- src/rshapes.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index ddd371f14d56..5533139550c9 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1141,7 +1141,8 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f } float stepLength = 90.0f/(float)segments; - const float outerRadius = radius + lineThick, innerRadius = radius; + const float outerRadius = radius + lineThick - 0.5f; + const float innerRadius = radius - 0.5f; /* Quick sketch to make sense of all of this, @@ -1162,20 +1163,20 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f const Vector2 point[16] = { {(float)rec.x + innerRadius + 0.5f, rec.y - lineThick + 0.5f}, {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y - lineThick + 0.5f}, - {rec.x + rec.width + lineThick - 0.5f, (float)rec.y + innerRadius - 0.5f}, // PO, P1, P2 - {rec.x + rec.width + lineThick - 0.5f, (float)(rec.y + rec.height) - innerRadius + 0.5f}, + {rec.x + rec.width + lineThick - 0.5f, (float)rec.y + innerRadius + 0.5f}, // PO, P1, P2 + {rec.x + rec.width + lineThick - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height + lineThick - 0.5f}, // P3, P4 {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height + lineThick - 0.5f}, {rec.x - lineThick + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {rec.x - lineThick + 0.5f, (float)rec.y + innerRadius + 0.5f}, // P5, P6, P7 {(float)rec.x + innerRadius + 0.5f, rec.y + 0.5f}, {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + 0.5f}, // P8, P9 - {rec.x + rec.width - 0.5f, (float)rec.y + innerRadius - 0.5f}, - {rec.x + rec.width - 0.5f, (float)(rec.y + rec.height) - innerRadius + 0.5f}, // P10, P11 + {rec.x + rec.width - 0.5f, (float)rec.y + innerRadius + 0.5f}, + {rec.x + rec.width - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, // P10, P11 {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height - 0.5f}, {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height - 0.5f}, // P12, P13 - {rec.x + 0.5f, (float)(rec.y + rec.height) - innerRadius + 0.5f}, - {rec.x + 0.5f, (float)rec.y + innerRadius - 0.5f} // P14, P15 + {rec.x + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {rec.x + 0.5f, (float)rec.y + innerRadius + 0.5f} // P14, P15 }; const Vector2 centers[4] = {