-
Notifications
You must be signed in to change notification settings - Fork 8
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
Lines are blurry sometimes when using whole number coordinates #149
Comments
Hi, OCaml-Canvas' behavior should match the HTML5 Canvas behavior. |
Ahhh ok, I think I’m understanding it better now (my mental model was wrong). So the lines lie on the middle of the pixel, and that’s why they are coming out blurry? I think the end-caps are also lying in the middle of the pixel as well – eg. if I used butt endcaps it wouldn’t be blurry. Seems like for rectangles Firefox is putting the stroke “around” the fill rather than overlaying it on the center of the pixel? This seems potentially confusing, but I’m not sure if this is standard behavior for canvas implementations. |
Another interesting page that helps understand how coordinates map to pixels: http://html5tutorial.com/how-to-draw-a-point-with-the-canvas-api/. Anyways, lines and rectangle should behave the same way. However, testing a bit with https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_canvas_tut_path showed that Firefox's rect primitive behaves differently (its is likely a bug in Firefox...). |
I’m a bit confused about the behavior of line drawing… sometimes using whole numbers gives a crisp, non-blurry result, other times it requires using half-increments in either the x axis or y axis, or both. It’s a bit unpredictable! Here’s a test I came up with to exercise some of this:
On a highdpi display:
On a standard resolution display:
The code:
The text was updated successfully, but these errors were encountered: