Skip to content

Commit

Permalink
improve fix - (pixel offset issue with DrawRectangleRoundedLinesEx)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bigfoot71 committed Jan 8, 2025
1 parent f8f2b1a commit 2294c5c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/rshapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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] = {
Expand Down

0 comments on commit 2294c5c

Please sign in to comment.