No, this isn’t a bug, you’re just getting muddled.
The co-ords refer to the top-left of the pixels you’re drawing, so of course your other line is off the edge by one pixel, because you’re telling it to start drawing beyond the edges of the image.
I’m not shure if I understand. Maybe i make an
example
gg.drawLine(0,3, 3,0);
startX/startY mark the bottom left pixel,
and endX/endY mark the top right pixel.
Only one of these two pixels is drawn.
If you swap the start values and the end
values, then the result allways remains
the same.
For this example the top right pixel is
not drawn, because endY<startY.
And if endY==startY, as in
gg.drawLine(0,1, 3,1);
then the pixel with the higher X-value (3,1)
is not drawn.
It’s only an approximation - the line-drawing algorithm is designed to be fast, not to guarantee which pixels get filled. And if I eventually add support for other hardware-assisted rendering, there’s even less guarantee that it would always behave the same way.
If for some reason it actually matters exactly which pixels get drawn, just use fillRect to set each one. Or better: create a Path that covers the area, as that will always be rendered with sub-pixel accuracy.