Comment 23 for bug 165780

Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

Workaround:

1) dimension the objects which are to become a pattern in integer multiples of pixels
2) align them to a grid with 1x1 pixel spacing
-> now anti-aliasing has been avoided, next:
3) do not rotate the pattern.

I'm not sure if this is easily explained by calling this rounding bugs, it might be more complicated than that and simply inherent to the way things are currently handled by the renderer. I had a look at the relevant part of the source code (sp_pat_fill and sp_pattern_painter_new), but it's quite difficult to grasp what's going on. If I'm correct then the pattern is simply stamped over the object to be filled until the full area has been covered. So while steps 1) and 2) will work for orthogonal patterns, this will never get a perfect fill when rotating. Rounding errors are inevitable and cannot be avoided. We could only fight the symptoms by doing some clever interpolation/filtering/antialiasing or whatever. Or we should increase the pattern half a pixel in size or reduce the pattern pitch by half a pixel, but this would be foul play.

What might help in 3) is if we'd first create a temporary bitmap of e.g. a 3x3 orthogonal pattern (invisible to the user), rotate and transform that bitmap, and then cut a small rectangle (with the size of the original pattern) out of that rotated bitmap and use that small rectangle for stamping.

But IMHO that would be quite a challenge when looking at the state of the source code :-(