Skip to content
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] Review DrawRectangleLines() pixel offset #4261

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 + 1);
rlVertex2f((float)posX - zoomElement, (float)posY);
rlVertex2f((float)posX + (float)width + zoomElement, (float)posY);

rlVertex2f((float)posX + (float)width, (float)posY + 1);
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 + 1, (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 + 1, (float)posY + (float)height);
rlVertex2f((float)posX + 1, (float)posY + 1);
rlVertex2f((float)posX, (float)posY + (float)height + zoomElement);
rlVertex2f((float)posX, (float)posY - zoomElement);
rlEnd();
}

Expand Down
Loading