Make rounded rectangles more robust.

- rx and ry parameters are set to 0 if they're negative.
- automatic points calculation doesn't cause an unnecessarily large amount of points when rx or ry are greater than half the rectangle's size.
This commit is contained in:
Alex Szpakowski
2021-10-10 22:08:56 -03:00
parent 4a579bf2a7
commit 4574805486
+3 -2
View File
@@ -1350,7 +1350,7 @@ void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h)
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry, int points) void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry, int points)
{ {
if (rx == 0 || ry == 0) if (rx <= 0 || ry <= 0)
{ {
rectangle(mode, x, y, w, h); rectangle(mode, x, y, w, h);
return; return;
@@ -1409,7 +1409,8 @@ void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, floa
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry) void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry)
{ {
rectangle(mode, x, y, w, h, rx, ry, calculateEllipsePoints(rx, ry)); int points = calculateEllipsePoints(std::min(rx, std::abs(w/2)), std::min(ry, std::abs(h/2)));
rectangle(mode, x, y, w, h, rx, ry, points);
} }
void Graphics::circle(DrawMode mode, float x, float y, float radius, int points) void Graphics::circle(DrawMode mode, float x, float y, float radius, int points)