Produces a file that has a faint gray line one pixel wide on the left and top edges. What could be causing this, and is there a way to turn those lines off? I've uploaded the output file here
The line isn't actually there. Using 'eog', it appears to me as a dashed gray line. And then, using another viewer that did not fully support PNG transparency, there was no line at all. In Gimp, I didn't see a line either. If anything, either we have an off-by-one error in saving our files, or your display software and 'eog' has an off-by-one error.
Gimp shows the left and top pixel as being transparent, and by going to Colors -> Components -> Decompose -> Alpha you can see that the alpha channel will produce semi transparent left and top borders.
This is due to pixel-snapping. To get sharp lines, vertices are rounded to the nearest pixel. In the case of odd (i.e. non-even) stroke widths, the vertices are then shifted half a pixel down and to the right so their centers are on the center of the pixel.
The bug here is that the figure patch (the background of the figure) has a stroke width of 1.0, even through it was an edgecolor of None (i.e. it isn't actually drawn). So the entire rectangle gets shifted half a pixel down and to the right.
There are a number of ways to fix this, and I think we should probably do all of them to cover all bases, even though any one of them is sufficient for the problem at hand.
Set the default stroke width of the figure patch to 0.0
Change the snapping algorithm so there is no half-pixel adjustment when there is a stroke width but no stroke color
Draw the figure patch with anti-aliasing turned off, since it's always a solid rectangle (has the advantage of being faster, too)
Activity
WeatherGod commented on May 17, 2011
The line isn't actually there. Using 'eog', it appears to me as a dashed gray line. And then, using another viewer that did not fully support PNG transparency, there was no line at all. In Gimp, I didn't see a line either. If anything, either we have an off-by-one error in saving our files, or your display software and 'eog' has an off-by-one error.
astrofrog commented on May 17, 2011
It must be something to do with the alpha channel. I see the 'line' in Preview.app, and also if I convert to a different format using imagemagick:
astrofrog commented on May 17, 2011
Gimp shows the left and top pixel as being transparent, and by going to Colors -> Components -> Decompose -> Alpha you can see that the alpha channel will produce semi transparent left and top borders.
Fix bug where there was a thin semitransparent line on the upper and …
mdboom commented on May 17, 2011
This is due to pixel-snapping. To get sharp lines, vertices are rounded to the nearest pixel. In the case of odd (i.e. non-even) stroke widths, the vertices are then shifted half a pixel down and to the right so their centers are on the center of the pixel.
The bug here is that the figure patch (the background of the figure) has a stroke width of 1.0, even through it was an edgecolor of None (i.e. it isn't actually drawn). So the entire rectangle gets shifted half a pixel down and to the right.
There are a number of ways to fix this, and I think we should probably do all of them to cover all bases, even though any one of them is sufficient for the problem at hand.
A solution is on my figure_edge branch.
astrofrog commented on May 17, 2011
@mdboom - that patch fixes the issue for me
I have another issue with similar symptoms which is not fixed by the patch, so I've opened a new issue (#118)
Fix bug where there was a thin semitransparent line on the upper and …