diff --git a/src/rshapes.c b/src/rshapes.c index 81f106fa4..4e7374260 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -960,22 +960,35 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, Col \ / P5 ------------------ P4 */ + + // The x-coordinates used for the outline + const float x0 = rec.x + radius + 0.5f; + const float x1 = (rec.x + rec.width) - radius - 0.5f; + const float x2 = rec.x + rec.width - 0.5f; + const float x3 = rec.x + 0.5f; + + // The y-coordinates used for the outline + const float y0 = rec.y + 0.5f; + const float y1 = rec.y + radius + 0.5f; + const float y2 = (rec.y + rec.height) - radius - 0.5f; + const float y3 = rec.y + rec.height - 0.5f; + const Vector2 point[8] = { - {(float)rec.x + radius + 0.5f, rec.y + 0.5f}, - {(float)(rec.x + rec.width) - radius - 0.5f, rec.y + 0.5f}, - {rec.x + rec.width - 0.5f, (float)rec.y + radius + 0.5f}, // PO, P1, P2 - {rec.x + rec.width - 0.5f, (float)(rec.y + rec.height) - radius - 0.5f}, - {(float)(rec.x + rec.width) - radius - 0.5f, rec.y + rec.height - 0.5f}, // P3, P4 - {(float)rec.x + radius + 0.5f, rec.y + rec.height - 0.5f}, - {rec.x + 0.5f, (float)(rec.y + rec.height) - radius - 0.5f}, - {rec.x + 0.5f, (float)rec.y + radius + 0.5f}, // P5, P6, P7 + {x0, y0}, // P0 + {x1, y0}, // P1 + {x2, y1}, // P2 + {x2, y2}, // P3 + {x1, y3}, // P4 + {x0, y3}, // P5 + {x3, y2}, // P6 + {x3, y1}, // P7 }; const Vector2 centers[4] = { - {(float)rec.x + radius + 0.5f, (float)rec.y + radius + 0.5f}, - {(float)(rec.x + rec.width) - radius - 0.5f, (float)rec.y + radius + 0.5f}, // P16, P17 - {(float)(rec.x + rec.width) - radius - 0.5f, (float)(rec.y + rec.height) - radius - 0.5f}, - {(float)rec.x + radius + 0.5f, (float)(rec.y + rec.height) - radius - 0.5f} // P18, P19 + {x0, y1}, // P16 + {x1, y1}, // P17 + {x1, y2}, // P18 + {x0, y2} // P19 }; const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };