-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
draw_rectangle_lines
with thickness 1.0
only draws half of the rectangle
#704
Comments
I'm working on a pixel art game and this has been an absolute nightmare. I've tried messing around with different thicknesses and I can never get a perfect rectangle. The problem also extends to drawing simple lines as well, if you try to draw a rectangle out of lines very often the corners will be missing. I really get the impression that the cause of this bug is weirdness with floating point numbers, maybe it would be appropriate to have a second set of drawing functions that take in integer coordinates? After quite a bit of experimentation, I've come up with this which seems to render an entire rectangle with corners quite consistently. The main thing is to round all coordinates and then add a small epsilon to the coordinate of the top corner. Here's what I've come up with. It's really dirty, but it gets the job done. Your mileage may vary and this might require some adjustment depending on what you're doing. let x = x.round();
let y = y.round();
let w = w.round();
let h = h.round();
const EPSILON: f32 = 0.5;
draw_rectangle_lines(x, y, w, h, 1.0, WHITE);
draw_line(x + EPSILON, y + EPSILON, x + w, y, 1.0, WHITE);
draw_line(x + w, y + EPSILON, x + w, y + h, 1.0, WHITE);
draw_line(x + w, y + h, x, y + h, 1.0, WHITE);
draw_line(x + EPSILON, y + h, x, y, 1.0, WHITE);
|
idk if this is a good solution but I was able to fix this by changing line 55 in |
Hi,
I have no idea if this is on purpose, but with macroquad v0.4.5, when I use
draw_rectangle_lines
with a thickness of1.0
I only get half of the rectangle drawn. It works fine with a thickness of2.0
.Code to reproduce:
Sample image:
Is this a bug or does this have to do with some other setting?
/walter
The text was updated successfully, but these errors were encountered: