In both the simulator and on hardware running 1.12.3, the C API drawLine appears to "overdraw" by one pixel for certain line widths.
I am reproducing this on macOS; and haven't tried on other OS'es nor have tried this with a Lua implementation.
Steps to reproduce:
- Draw a horizontal or vertical line at
width0or1- e.g.:
playdate->graphics->drawLine(0, 0, 10, 0, 1, kColorBlack)- will result in a line that is rendered
11pixels in length, rather than the expected10
- will result in a line that is rendered
- e.g.:
Expected result:
- The line is drawn with the given length (eg: either
x2 - x1for horizontal lines, ory2 - y1for vertical lines).
Observed result:
- The line is drawn with a length + 1 from what I would expect; but only for
width1(horizontal lines) andwidth0or1(vertical lines)
Diagonal line drawing may similarly be affected, I haven't investigated this yet.
Directionality of drawing the line does not affect the bug. The "overdraw" always occurs in the rightmost or bottommost direction.
Here is display output from a sample project that reproduces the issue. It draws 10 equal-length lines, increasing in width from 0 to 9. The lines are drawn in both "directions" (eg: left-to-right, right-to-left, top-to-bottom, bottom-to-top).
-
Raw output of drawing the various lines:
-
A marked up version of the previous image, with an overlay to highlighting the issue. You may still need to zoom to observe it; it's difficult to see at 1x scale.
Also, for convenience in reproducing:
-
A pre-build
pdxthat should run in the simulator or hardware:- 1_drawline_pdx.zip (3.9 KB)
-
A complete project bundle with additional comments. NOTE: This is a single source project; if the SDK is on your path you should be able to
maketo build it and use the producedpdx.- 1_drawline_project.zip (5.3 KB)

