Skip to content

Commit

Permalink
... and replace it with a -/+ 0.5 offset divided by current cam's zoom.
Browse files Browse the repository at this point in the history
  • Loading branch information
RadsammyT committed Aug 17, 2024
1 parent b26b1c0 commit ce3e35d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/rshapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,19 +811,21 @@ void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3,
// but it solves another issue: https://github.com/raysan5/raylib/issues/3884
void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
{
Matrix mat = rlGetMatrixModelview();
float zoomElement = 0.5f / mat.m0;
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f((float)posX, (float)posY);
rlVertex2f((float)posX + (float)width, (float)posY);
rlVertex2f((float)posX - zoomElement, (float)posY);
rlVertex2f((float)posX + (float)width + zoomElement, (float)posY);

rlVertex2f((float)posX + (float)width, (float)posY);
rlVertex2f((float)posX + (float)width, (float)posY + (float)height);
rlVertex2f((float)posX + (float)width, (float)posY - zoomElement);
rlVertex2f((float)posX + (float)width, (float)posY + (float)height + zoomElement);

rlVertex2f((float)posX + (float)width, (float)posY + (float)height);
rlVertex2f((float)posX, (float)posY + (float)height);
rlVertex2f((float)posX + (float)width + zoomElement, (float)posY + (float)height);
rlVertex2f((float)posX - zoomElement, (float)posY + (float)height);

rlVertex2f((float)posX, (float)posY + (float)height);
rlVertex2f((float)posX, (float)posY);
rlVertex2f((float)posX, (float)posY + (float)height + zoomElement);
rlVertex2f((float)posX, (float)posY - zoomElement);
rlEnd();
}

Expand Down

0 comments on commit ce3e35d

Please sign in to comment.