-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rshapes] DrawRectangleRounded
draws a regular rectangle if width or height < 1
#4673
Comments
@teatwig Please, could you post some image of the resulting drawn rectangle? Afaik, it's not possible to really draw a sub-pixel element... but I could be wrong... Also note that |
I tested it again with the latest commit from master (08b089f). This is my program: int main(void)
{
const int width = 800;
const int height = 600;
InitWindow(width, height, "rounded rect test");
Camera2D camera = { 0 };
camera.zoom = height;
Rectangle rect = { 0.1f, 0.1f, 0.8f, 0.8f };
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode2D(camera);
DrawRectangleRounded(rect, 0.4f, 3, BLACK);
EndMode2D();
EndDrawing();
}
CloseWindow();
return 0;
} With the following patch that disables the check: --- a/src/rshapes.c
+++ b/src/rshapes.c
@@ -884,7 +884,7 @@ void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color)
void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color)
{
// Not a rounded rectangle
- if ((roundness <= 0.0f) || (rec.width < 1) || (rec.height < 1 ))
+ if (roundness <= 0.0f)
{
DrawRectangleRec(rec, color);
return; |
@teatwig should a pixel have rounded corners? please, could you explain some use-case? |
I think we shouldn't think of the dimensions of I was mostly wondering why this check exists, and it's nice that I can adjust raylib so it works slightly better for my use case 😄 |
Issue description
Since
Rectangle
accepts floats forwidth
andheight
it was a bit surprising to me that you can't draw rounded rectangles that have either be smaller than 1.See: https://github.com/raysan5/raylib/blob/master/src/rshapes.c#L887
My rectangle is drawn with world coordinates between 0.0 and 1.0, which are then scaled to the full size with Camera2D.
If I remove the check it works without issues, so I assume this is a leftover from some earlier behavior?
Environment
Linux, raylib 5.5
Code Example
I'm using the Elixir bindings, but it's really just any rectangle with width or height < 1:
The text was updated successfully, but these errors were encountered: